Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)
The simple 'pop up a readme text message' bit is very easy in Python. If you download and install some Freestuff from Renderosity for Poser, then look in your Poser library, you'll probably find a working example of someone already doing that. For the causal editing of one of these, the Python .PY file is best opened and edited and save from the Notepad++ freeware on Windows.
But it sounds like what you'd actually like is a dynamic 'Notepad in Poser' script doing the following:
1. Start the 'script maker' script, a new panel appears, into which the user types in some text and then presses "save".
2. The script saves the typed text as a new 'readme' .PY file, in the current Library folder. And alongside it adds a standard PNG icon saying "My Notes".
3. Each new user-created note persist in the runtime, and can be consulted in the future by going to the relevant folder. Possibly the user can also edit this earlier text on an ongoing basis, and save the new version.
Learn the Secrets of Poser 11 and Line-art Filters.
Here's a simple example, with line-breaks and controls on the size of the panel that opens:
Learn the Secrets of Poser 11 and Line-art Filters.
This is very helpful. I copied your information and pasted it, got it to work. I was trying to type a lot of text and the dialog box wound up being to narrow, the text disappeared off to the sides. Is there a way to have the text go onto the next line and have scroll bars if there is a lot of text? Some of my readme's get wordy.
That's where the \n comes in. It forces a line-wrap ('new line').
Learn the Secrets of Poser 11 and Line-art Filters.
Ideally such messages are for prompting or reassuring the user, not for long readme files that need to be studied. You can also launch a PDF from a click on a Library icon for a script, which might be better in this case.
Learn the Secrets of Poser 11 and Line-art Filters.
If that interests you, you could also drop for example a CM2 file in a Pose folder, with a text file lying at the same place.
Example with a t.cm2, a t.py and a readme.txt files:
t.cm2:
{
version
{
number 9
}
runPythonScriptEx ":t.py" Readme.txt
}
then, the t.py Python file looks like this:
this Python script runs with Poser11 & Poser12. Tested on Windows.
The only pitfall: I have not found any way to change the colors: this is Poser's default run windows, and it's written in black on a white background. Nothing sexy.
𝒫𝒽𝓎𝓁
(っ◔◡◔)っ
👿 Win11 on i9-13900K@5GHz, 64GB, RoG Strix B760F Gamng, Asus Tuf Gaming RTX 4070 OC Edition, 1 TB SSD, 6+4+8TB HD
👿 Mac Mini M2, Sequoia 15.2, 16GB, 500GB SSD
👿 Nas 10TB
👿 Poser 13 and soon 14 ❤️
@HartyBart: I was able to alter the width and height of the popup window so it was large enough to accommodate all the text. I did have to guess where to do the line break since all the text is centered instead of left justified. Thanks for you help! This is a lot better method that I used do which what cram as much text onto a png file that showed up in the library.
@Y-Phil: This is exactly what I was looking for and it works perfectly (after figuring out I needed to rename my source files). Is there any way you know if to make the box wider perchance? It's not necessary since it has scrolling, but I'm just curious.
Thank you guys for your replies and help!
Maybe this is a bit more flexible:
"""
Create a Poser CR2 file with content similar to this:
{
version
{
number 11
}
runPythonScript "html/HtmlDialog.py"
}
Create a directory named "html" as a subdirectory where the CR2 file is located.
This subdirectory must contain the Python file called in the CR2 file.
The Python file contains the script below to display an HTML or text file.
In the demo script, the file must have the same name as the Python script,
but end in "html". HTML code must have a simple form only (no javascript
for example).
If the script is called "HtmlDialog.py", then the file to be displayed must
be called "HtmlDialog.html". Both can be changed as needed, of course.
All attributes of the used wx.html.HtmlWindow() class can be reached via
the dialog class (e.g. wx.html.HtmlWindow.LoadFile()
see https://docs.wxpython.org/wx.html.HtmlWindow.html.
"""
from __future__ import print_function
import sys, os, wx
from wx import html
try:
import poser
except ImportError:
import POSER_FAKE_12 as poser
html_file = os.path.join(os.path.abspath(sys.argv[0]).rsplit(".", 1)[0] + ".html")
class HtmlDialog(wx.Dialog):
def __init__(self, parent):
wx.InitAllImageHandlers()
super(HtmlDialog, self).__init__(parent, id=wx.ID_ANY, title="INFO",
style=wx.DEFAULT_DIALOG_STYLE |
wx.RESIZE_BORDER |
wx.STAY_ON_TOP)
self.browser = html.HtmlWindow(self, id=wx.ID_ANY, name="browser")
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.browser, 1, wx.EXPAND)
self.SetSizerAndFit(sizer)
self.SetSize(500, 600)
def __getattr__(self, item):
return self.browser.__getattribute__(item)
if __name__ == "__main__":
dialog = HtmlDialog(None)
dialog.LoadFile(html_file)
dialog.SetSize(800, -1)
dialog.Show()
The forum editor has once again destroyed the formatting. The intact source can be downloaded here:
This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.
I have no idea how python works, but I'm wondering if you can create a script or program that does something like this:
The image above shows that an icon in the library can open up a text window the click 'ok' to have it close. It's like pulling up a readme file directly from the library.
Can this be done in poser? I had to copy a dsa file (daz studio text file) and edit the wording, but it still works. I can copy the dsa file to any folder, edit the text, then save it. When I click on the icon from the library, the dsa file opens up and it can be closed. I'd love to see something like this for Poser, a pop up window with info in it then close it.
Maybe a python script you can open up a dialog, add your read me notes and save it to a specific folder in your runtime libraries. Then you can create a png file.
Any thoughts?