Well, this was what I used to test it:
Really the best thing is to include the whole runnable chunk of code as an attachment. In order to get your code to run I had to copy and paste this part and then go back to the first message and get the rest of it. Not complaining, but it is just good policy to have the question asker provide an everything-included way to test someone’s problematic code.
if name == ‘main’:
app = wx.PySimpleApp()
dia = SizeDialog(None, -1, ‘test’, (16,24))
r = dia.ShowModal()
if r == wx.OK:
print 'You pressed OK! Size: {0}x{1}'.format(dia.width.GetValue(),dia.height.GetValue())
elif r == wx.CANCEL:
print 'You pressed Cancel!'
else:
print 'You pressed... nothing.'
print r
dia.Destroy()
app.MainLoop()
Adding the sizer did make the TextCtrls and StaticText visible more like they were supposed to be, but the buttons still aren’t visible. Also, I don’t quite understand why explicitly defining a sizer would be necessary… It wasn’t necessary on my frame class.
It wasn’t necessary on a frame because a frame automatically resizes the first panel on it to be the full size of the frame–dialogs don’t do that. (They sort of already are a frame with a panel on it, so to speak).
Try the attached code. The difference is I did away with your panel, since with this dialog you don’t need one, and that simplifies it and may be what you need.
No, no one mentioned anything to me about meaningful names. I was already pestered about that in Visual Basic class (heck, we even had to meaningfully name temporary loop variables!), and I have since dropped writing 20+ character long names in favor of shorter (more practical) names. Sure I could call the box something like szrTopHorizontalBox, but why use such a long and complicated name when I can just call it hbox?
Sorry it was to someone named Seb from Ray. It’s a personal choice of course, but my feeling is if you call something txtWidth it should be a width value and not actually a text control. hbox is not complicated but it is also not informative. It could be a box-like panel, it could be a StaticBox… It’s a sizer, so I’d at least get the word “sizer” in there, as in hboxsizer. For larger sections of code I might even put something like textCtrlsBoxSizer. The reason is when you later go back to revise/fix your code, it will be so much more readable and easier to work on when you compare “hbox” to “textCtrlsBoxSizer” (then again, I actually sort of liked the IUPAC chemicals naming conventions… :D)
Che
dialog_simpler.py (1.29 KB)
···
On Sat, Jul 24, 2010 at 12:18 AM, 音本四 onpon4@gmail.com wrote: