Robin Dunn wrote:
Stef Mientki wrote:
Now these are my observations, after launching the ColorDlg from the Popup_Form,
which I can't explain:
1. OK: the Main_Form can not be reached
2. WRONG: the Popup_Form and other Popup_Forms CAN be reached
3. WRONG: from another Popup_Form, I can launch the ColorDlg also,
which creates a new ColorDlg (while the old one also stays)
but this ColorDlg is the MainForm's ColorDlg, so how can there be 2 instances of the same ColorDlg ??
4. VERY WRONG: After opening a ColorDlg from a Popup_Form,
trying to launch from the same Popup_Form, launches 2 extra instances of a ColorDlg, so I have 3 for the same Popup ???
5. VERY WRONG: After opening a ColorDlg, selecting a color so the ColorDlg closes,
now launching the ColorDlg from the same PopupForm, always shows 2 instances of a colordlg,
sometimes both are working normally, sometimes 1 of the colordialogs doesn't refresh well (you erase the colors by moving another program over it)
Please send a small runnable sample that shows the problem so we can see exactly what you are doing.
Ok I hope I made it small enough.
The program has become very dirty now (e.g. not closing dynamically created forms),
and unfortunately my remarks 4 and 5 don't happen in this short version
or 
After starting the program,
a mainform with 2 ogl circles ("devices" ) is shown.
Right clicking on each circle will show a menu (with just 1 item),
clicking on this menu item, will popup the properties form of this device,
which in this case is just a button.
Pressing this button, will popup the famous colordialog,
and see the remarks 2 and 3 happen.
(btw, I run under winXP)
thanks,
Stef Mientki
colordialog_problem.py (8.47 KB)
Sounds reasonable logic what you're saying, Stephen.
didn't know you could set custom colors,
if so I don't need the complex construct,
so I'll try and will report back.
thanks,
Stef
Stephen Hansen wrote:
ยทยทยท
The problem is, I believe, that you're trying to have a single color dialog that is owned by the main parent, and then invoke it in a modal fashion by children.
A modal dialog blocks its parent (and parents' parents) from gaining interactivity-- but not other arbitrary windows.. intentionally. Sometimes that's important to be able to do.
What you need to do is just store the *colordata* on the parent.
So, on the child do:
dlg = wx.ColourDialog(self, self.mainDialog.colordata)
result = dlg.ShowModal()
self.mainDialog.colordata = dlg.GetColourData()
And on the parent set 'colordata' to None at first, then everytime a child runs it, it updates the parent's colordata attribute... the colordata attribute stores the various custom colors/etc.
On 7/18/07, *Stef Mientki* <s.mientki@ru.nl <mailto:s.mientki@ru.nl>> > wrote:
Guilherme Polo wrote:
> 2007/7/18, Stef Mientki <s.mientki@ru.nl <mailto:s.mientki@ru.nl>>:
>> Someone just ran the (large) program on Ubuntu,
>> and everything worked as expected.
>
> It seems the problem lies on how each window manager handles
windows.
Well it's not normal windows behavior, so either
- I've set something wrong
- there is a bug in wxwidgets
- there is a bug in wxPython
>
>> So should we do something special under winXP,
>> or is it maybe a bug in the windows implementation of wxwidgets /
>> wxpython ?
>
> It seems you need to change your code design.
>
yeah, but how ?
this seems a rather principal problem to me,
if you can't define modal forms, it's almost impossible to write
GUI 
any suggestions ?
The root of the problem is that the wx.ColourDialog (and other common dialogs) are not real wx.Dialogs. Their ShowModal method is just a wrapper around the platform API function that creates and shows the platform's native color selector or whatever. In this case it appears that Windows it not enforcing app modality, so it is letting you click on other widgets that are not the dialog's parent window and that happen to also call the color dialog's ShowModal and so it calls the API function again...
thanks Robin,
That explains indeed all the behavior I see.
There is a generic color selector panel in the library that would let you implement your own class derived from wx.Dialog, which would end up working similarly to how you seem to be expecting things to happen. Or you can restructure your program to create the color dialog's on demand with the property window as the parent, and make your property windows be dialogs too. I think that will also get you close to what you are wanting.
thanks for the ideas,
I just saw there is also a wx.ColourPickerControl, does this form has application modal behavior ?
For the moment, I've introduced a flag, that indicates if a colordialog is open,
with this flag I can at least block closure of the applicatio, which is enough for now.
Also many thanks to all others in this discussion,
I've learned a lot,
and it's a joy to see how cooperative everyone on this list is.
cheers,
Stef Mientki