emulating dialog with frame

Dear all,
I'm trying to emulating a dialog with a frame, 'cos I need a manubar
in the dialog.
I'm using the wx.Frame.MakeModal to do this.

There is some problem in the visualization that I cannot understand,
namely the two buttons are not plotted in the GUI.
Can anyone understand where is the problem?Thanks:

the code:

#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
# generated by wxGlade 0.6.3 on Fri May 14 13:53:18 2010

import wx
import gettext
import os,sys

class MyDropDialog2(wx.Frame):
    def __init__(self, list, *args, **kwds):
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.panel_1 = wx.Panel(self, -1)
        # Menu Bar
        self.frame_1_menubar = wx.MenuBar()
        wxglade_tmp_menu = wx.Menu()
        self.frame_1_menubar.Append(wxglade_tmp_menu, _("Languges"))
        self.SetMenuBar(self.frame_1_menubar)
        # Menu Bar end
        self.frame_1_statusbar = self.CreateStatusBar(1, 0)
        self.label_1 = wx.StaticText(self.panel_1, -1, _("USER"),
style=wx.ALIGN_CENTRE)
        self.combo_box_1 = wx.ComboBox(self.panel_1, -1, choices=list,
style=wx.CB_DROPDOWN|wx.CB_DROPDOWN|wx.CB_READONLY)
        self.button_OK = wx.Button(self, wx.ID_OK, _("ok"))
        self.button_CANCEL = wx.Button(self, wx.ID_CANCEL,
_("cancel"))
        self.button_OK.Bind(wx.EVT_BUTTON,self.OnOk)
        self.button_CANCEL.Bind(wx.EVT_BUTTON,self.OnCancel)
        self.UsrChoice = 0
        self.Bind(wx.EVT_CLOSE,self.OnCancel)

        self.__set_properties()
        self.__do_layout()
        self.__ShowModal()

    def __set_properties(self):

        self.SetTitle(_("USER SELECTION"))
        self.frame_1_statusbar.SetStatusWidths([-1])
        # statusbar fields
        frame_1_statusbar_fields = [_("select user and press OK")]
        for i in range(len(frame_1_statusbar_fields)):

self.frame_1_statusbar.SetStatusText(frame_1_statusbar_fields[i], i)
        self.label_1.SetFont(wx.Font(16, wx.DEFAULT, wx.NORMAL,
wx.BOLD, 0, ""))
        self.combo_box_1.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL,
wx.NORMAL, 0, "MS Shell Dlg 2"))
        self.combo_box_1.SetSelection(0)
        self.button_OK.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL,
wx.BOLD, 0, ""))
        self.button_CANCEL.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL,
wx.BOLD, 0, ""))

    def __do_layout(self):
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_2 = wx.BoxSizer(wx.VERTICAL)
        sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_2.Add(self.label_1, 0, wx.ALL|
wx.ALIGN_CENTER_HORIZONTAL, 5)
        sizer_2.Add(self.combo_box_1, 0, wx.ALL|
wx.ALIGN_CENTER_HORIZONTAL, 5)
        sizer_2.Add((20, 10), 0, wx.EXPAND, 0)
        sizer_3.Add(self.button_OK, 0, wx.ALL|
wx.ALIGN_CENTER_HORIZONTAL, 10)
        sizer_3.Add((20, 20), 0, 0, 0)
        sizer_3.Add(self.button_CANCEL, 0, wx.ALL, 10)
        sizer_2.Add(sizer_3, 0, 0, 0)
        self.panel_1.SetSizer(sizer_2)
        sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()
        print "__do_layout"

    def __ShowModal(self):
        self.Show()
        self.MakeModal()
        self.eventLoop = wx.EventLoop()
        self.eventLoop.Run()
        print "__ShowModal"
    def GetStringSelection(self):
        return self.combo_box_1.GetStringSelection()
    def GetSelection(self):
        return self.combo_box_1.GetSelection()
    def OnOk(self,event):
        print "OnOk"
        self.UsrChoice = 1
        self.eventLoop.Exit()
        return 1
    def OnCancel(self,event):
        self.eventLoop.Exit()
        return 0

# end of class MyDropDialog2

class MyAppGUI(wx.App):
    def OnInit(self):
        # Hack to get the locale directory
        basepath =
os.path.abspath(os.path.dirname(sys.argv[0]))#retrieve the name of the
directory
        localedir = os.path.join(basepath, "locale")
        langid = (wx.LANGUAGE_DEFAULT, wx.LANGUAGE_GERMAN,
wx.LANGUAGE_ENGLISH, wx.LANGUAGE_ITALIAN, wx.LANGUAGE_FRENCH,
wx.LANGUAGE_SPANISH) # to OS default;wx.LANGUAGE_DEFAULT or use
LANGUAGE_ENGLISH,_ITALIAN, etc.
        domain = "MyLocal" # the translation file is
MyApp.mo

        # Set up Python's gettext
        mylocale=[]
        trans=[]
        for LID in langid:
            # Set locale for wxWidgets
            mylocale.append(wx.Locale(LID))
            mylocale[-1].AddCatalogLookupPathPrefix(localedir)
            mylocale[-1].AddCatalog(domain)
            trans.append(gettext.translation(domain, localedir,
            [mylocale[-1].GetCanonicalName()], fallback = True))

        trans[0].install()#install the defalut
        self.trans=trans#you'll pass this to the frame
        self.locale=mylocale
        usrlist=(['ciao','miao'])
        usrselect=MyDropDialog2(usrlist,None,-1,'')#build the
dialog

        if usrselect.UsrChoice==1:
            print "in"
        else:
            usrselect.Destroy()
            print('closing')
            #self.Destroy()
            return 1

#-----start from python
if __name__ == "__main__":
    ext_device=2 #this should be given by the API

    #gettext.install("MyApp") # replace with the appropriate catalog
name

    MyApp = MyAppGUI(0)#0 to redirect the output
    MyApp.MainLoop()
    print('terminating application')

···

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Funny enough, only buttons gives me problems...I really have no
clue...

···

On 14 Mag, 15:31, tinauser <tinau...@libero.it> wrote:

Dear all,
I'm trying to emulating a dialog with a frame, 'cos I need a manubar
in the dialog.
I'm using the wx.Frame.MakeModal to do this.

There is some problem in the visualization that I cannot understand,
namely the two buttons are not plotted in the GUI.
Can anyone understand where is the problem?Thanks:

the code:

#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
# generated by wxGlade 0.6.3 on Fri May 14 13:53:18 2010

import wx
import gettext
import os,sys

class MyDropDialog2(wx.Frame):
def __init__(self, list, *args, **kwds):
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.panel_1 = wx.Panel(self, -1)
# Menu Bar
self.frame_1_menubar = wx.MenuBar()
wxglade_tmp_menu = wx.Menu()
self.frame_1_menubar.Append(wxglade_tmp_menu, _("Languges"))
self.SetMenuBar(self.frame_1_menubar)
# Menu Bar end
self.frame_1_statusbar = self.CreateStatusBar(1, 0)
self.label_1 = wx.StaticText(self.panel_1, -1, _("USER"),
style=wx.ALIGN_CENTRE)
self.combo_box_1 = wx.ComboBox(self.panel_1, -1, choices=list,
style=wx.CB_DROPDOWN|wx.CB_DROPDOWN|wx.CB_READONLY)
self.button_OK = wx.Button(self, wx.ID_OK, _("ok"))
self.button_CANCEL = wx.Button(self, wx.ID_CANCEL,
_("cancel"))
self.button_OK.Bind(wx.EVT_BUTTON,self.OnOk)
self.button_CANCEL.Bind(wx.EVT_BUTTON,self.OnCancel)
self.UsrChoice = 0
self.Bind(wx.EVT_CLOSE,self.OnCancel)

    self\.\_\_set\_properties\(\)
    self\.\_\_do\_layout\(\)
    self\.\_\_ShowModal\(\)

def \_\_set\_properties\(self\):

    self\.SetTitle\(\_\(&quot;USER SELECTION&quot;\)\)
    self\.frame\_1\_statusbar\.SetStatusWidths\(\[\-1\]\)
    \# statusbar fields
    frame\_1\_statusbar\_fields = \[\_\(&quot;select user and press OK&quot;\)\]
    for i in range\(len\(frame\_1\_statusbar\_fields\)\):

self.frame_1_statusbar.SetStatusText(frame_1_statusbar_fields[i], i)
self.label_1.SetFont(wx.Font(16, wx.DEFAULT, wx.NORMAL,
wx.BOLD, 0, ""))
self.combo_box_1.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL,
wx.NORMAL, 0, "MS Shell Dlg 2"))
self.combo_box_1.SetSelection(0)
self.button_OK.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL,
wx.BOLD, 0, ""))
self.button_CANCEL.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL,
wx.BOLD, 0, ""))

def \_\_do\_layout\(self\):
    sizer\_1 = wx\.BoxSizer\(wx\.VERTICAL\)
    sizer\_2 = wx\.BoxSizer\(wx\.VERTICAL\)
    sizer\_3 = wx\.BoxSizer\(wx\.HORIZONTAL\)
    sizer\_2\.Add\(self\.label\_1, 0, wx\.ALL|

wx.ALIGN_CENTER_HORIZONTAL, 5)
sizer_2.Add(self.combo_box_1, 0, wx.ALL|
wx.ALIGN_CENTER_HORIZONTAL, 5)
sizer_2.Add((20, 10), 0, wx.EXPAND, 0)
sizer_3.Add(self.button_OK, 0, wx.ALL|
wx.ALIGN_CENTER_HORIZONTAL, 10)
sizer_3.Add((20, 20), 0, 0, 0)
sizer_3.Add(self.button_CANCEL, 0, wx.ALL, 10)
sizer_2.Add(sizer_3, 0, 0, 0)
self.panel_1.SetSizer(sizer_2)
sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
self.Layout()
print "__do_layout"

def \_\_ShowModal\(self\):
    self\.Show\(\)
    self\.MakeModal\(\)
    self\.eventLoop = wx\.EventLoop\(\)
    self\.eventLoop\.Run\(\)
    print &quot;\_\_ShowModal&quot;
def GetStringSelection\(self\):
    return self\.combo\_box\_1\.GetStringSelection\(\)
def GetSelection\(self\):
    return self\.combo\_box\_1\.GetSelection\(\)
def OnOk\(self,event\):
    print &quot;OnOk&quot;
    self\.UsrChoice = 1
    self\.eventLoop\.Exit\(\)
    return 1
def OnCancel\(self,event\):
    self\.eventLoop\.Exit\(\)
    return 0

# end of class MyDropDialog2

class MyAppGUI(wx.App):
def OnInit(self):
# Hack to get the locale directory
basepath =
os.path.abspath(os.path.dirname(sys.argv[0]))#retrieve the name of the
directory
localedir = os.path.join(basepath, "locale")
langid = (wx.LANGUAGE_DEFAULT, wx.LANGUAGE_GERMAN,
wx.LANGUAGE_ENGLISH, wx.LANGUAGE_ITALIAN, wx.LANGUAGE_FRENCH,
wx.LANGUAGE_SPANISH) # to OS default;wx.LANGUAGE_DEFAULT or use
LANGUAGE_ENGLISH,_ITALIAN, etc.
domain = "MyLocal" # the translation file is
MyApp.mo

    \# Set up Python&#39;s gettext
    mylocale=\[\]
    trans=\[\]
    for LID in langid:
        \# Set locale for wxWidgets
        mylocale\.append\(wx\.Locale\(LID\)\)
        mylocale\[\-1\]\.AddCatalogLookupPathPrefix\(localedir\)
        mylocale\[\-1\]\.AddCatalog\(domain\)
        trans\.append\(gettext\.translation\(domain, localedir,
        \[mylocale\[\-1\]\.GetCanonicalName\(\)\], fallback = True\)\)

    trans\[0\]\.install\(\)\#install the defalut
    self\.trans=trans\#you&#39;ll pass this to the frame
    self\.locale=mylocale
    usrlist=\(\[&#39;ciao&#39;,&#39;miao&#39;\]\)
    usrselect=MyDropDialog2\(usrlist,None,\-1,&#39;&#39;\)\#build the

dialog

    if usrselect\.UsrChoice==1:
        print &quot;in&quot;
    else:
        usrselect\.Destroy\(\)
        print\(&#39;closing&#39;\)
        \#self\.Destroy\(\)
        return 1

#-----start from python
if __name__ == "__main__":
ext_device=2 #this should be given by the API

\#gettext\.install\(&quot;MyApp&quot;\) \# replace with the appropriate catalog

name

MyApp = MyAppGUI\(0\)\#0 to redirect the output
MyApp\.MainLoop\(\)
print\(&#39;terminating application&#39;\)

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visithttp://groups.google.com/group/wxPython-users?hl=en

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

OK,
Sorry to have bothered, I found the mistake: ii is due to the fact
that I used Glade...the buttons are not children of the panel,thats
why it doesnt work.

···

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en