From: Alex T. <al...@tw...> - 2004-06-21 20:52:28
|
At 10:02 21/06/2004 -0400, Schollnick, Benjamin wrote: >Maybe a silly question... But I do not see a easy way to make a >custom dialog? > >I guess I could power up resourceditor, make a "second" application >that looks like a custom dialog... > >But I would think there has to be a simple way to do that? Yes, it's pretty easy .... Fire up the resourceEditor Click on File/New... Dialog Template Move the "OK" and "Cancel" buttons down to make space Add a new Component/TextArea - call it something imaginative (TextArea1 in my case) Make it a suitable size, and set its font to Courier File/Save As ... mydialog.rsrc.py (see below) This also saves a file mydialog.py - edit this, to take an extra parameter "txt" and put it into self.components.TextArea1.text before displaying the dialog (see below) And then in your program simply call it as result = mydialog.myDialog(self, thetextstring) >The goal here is: > > * Switch to a monospaced font. The Scrolled Window font is > completely ruining any "table" design that I setup due > to the non-monospaced font... > > I just looked again and there is no wxpython nor pythoncard > documentation that talks about setting up the font for those > dialogs... Courier font - see example > * Maybe some other font "goodies"... Don't see any easy way ... > HTML would be nice, but is not necessary.... Make it a HTMLWindow instead of a TextArea example.rsrc.py by doing more or less what I described above {'type':'CustomDialog', 'name':'Template', 'title':'Dialog Template', 'position':(519, 120), 'size':(342, 301), 'components': [ {'type':'TextArea', 'name':'TextArea1', 'position':(10, 10), 'size':(309, 177), 'alignment':'left', 'font':{'faceName': 'Courier', 'family': 'sansSerif', 'size': 8}, 'text':'this is sample\ntext to show\nit is constant width\nmmmmmmmmmmmmmm\niiiiiiiiiiiiiiiii\n', }, {'type':'Button', 'id':5100, 'name':'btnOK', 'position':(75, 204), 'label':'OK', }, {'type':'Button', 'id':5101, 'name':'btnCancel', 'position':(177, 203), 'label':'Cancel', }, ] # end components } # end CustomDialog corresponding mydialog.py (note - slight editing needed to get this - basically just fixup the parameters and add the setting of self.components.TextArea1.text) from PythonCardPrototype import model class MyDialog(model.CustomDialog): def __init__(self, parent, txt=''): model.CustomDialog.__init__(self, parent) self.components.TextArea1.text = txt # if some special setup is necessary, do it here # example from samples/dialogs/minimalDialog.py # self.components.field1.text = txt #def myDialog(parent, txt): def myDialog(parent, txt): dlg = MyDialog(parent, txt) dlg.showModal() result = {'accepted':dlg.accepted()} # stick your results into the result dictionary here # example from samples/dialogs/minimalDialog.py # result['text'] = dlg.components.field1.text dlg.destroy() return result and finally the code snippet from the program itself (I added a button "showdialog" to trigger it) def on_showdialog_mouseClick(self, event): result = mydialog.myDialog(self, self.thestring) print result and sure enough it comes up, and is in Courier font. Hope this helps -- Alex. |