Reputation: 705
[PROBLEM] If I combine tkinter and wxpython then the app. window will freeze. Therefore please share a hint. I reckon that it has something to do with threads but I cannot quite put my finger on it.
[CODE]
from Tkinter import *
master = Tk()
def getFiles():
import wx
app = wx.App(False)
locale = wx.Locale(wx.LANGUAGE_ENGLISH)
frame = wx.Frame(None, wx.ID_ANY, "test", style=wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN)
frame.Center()
frame.SetBackgroundColour('LIGHTGREY')
frame.SetSize(200,400)
# Create grid manager instance
sizer = wx.GridBagSizer()
# Create Label for: Available testcase
entry = wx.StaticText( frame, wx.ID_ANY, u"Available testcases:", wx.DefaultPosition, wx.DefaultSize, 0 )
sizer.Add(entry,(1,1),(1,1),wx.EXPAND)
frame.SetSizerAndFit(sizer)
frame.Show(True) # Show the frame.
app.MainLoop()
b = Button(master, text="OK", command=lambda : getFiles())
b.pack()
master.mainloop()
[NOTE] I need wxpython because of : GenericDirCtrl object. I did not spot an identical obj in : tkinter, ttk, tix. Keep investigating
Upvotes: 1
Views: 1121
Reputation: 31
It's possible to combine Tkinter with wxPython as an independent module, for instance to use its advanced printing features. Try a line like this:
os.popen('PP4\wxprint_2.py "{}"'.format(fname)) # OK!
(wxprint_2.py is my wxPython standalone printing module)
The only problem is that on my PC, the printing module may bomb out at start-up without any warning or clue, probably because the memory limit is exceeded.
Upvotes: 0
Reputation: 9451
You cannot combine tkinter and wxPython. They are both GUI toolkits with their own event loops, which are basically infinite loops processing events from widgets. You cannot run two infinite loops at once.
However, there is probably also no reason to run both at once. If you need a widget which is not present in tkinter, just build your whole application with wxPython.
Upvotes: 4