473,325 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Embedded window in wxPython app

I've been experimenting with passing a window handle from a wxPython app to
a Tkinter app. The Tkinter app should embed a Toplevel window containing a
Canvas widget in the wxPython app's Frame (see example below).

Both apps run, but the Tkinter app's output doesn't appear.

Can anyone see why this isn't working?

Using wxPython-2.5.1/Python 2.3.3/Win98 and Win2000.

regards
Richard

----------------------------

#!/usr/bin/env python
# generated by wxGlade 0.3.3 on Thu Jun 03 14:36:32 2004

import wx
import os
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)

self.__set_properties()
self.__do_layout()
# end wxGlade
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("frame_1")
# end wxGlade

def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
self.Layout()
# end wxGlade
def StartSlave(self):
# Get the window id
window_id = str(self.GetHandle())
print 'In wx_app window_id =', window_id

script = 'tk_slave.py'
cmd = r"C:\python23\python.exe"
args = [script, script, window_id]
os.spawnv(os.P_NOWAIT, cmd, args)

#self.Refresh()
# end of class MyFrame
class MyApp(wx.App):
def OnInit(self):
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
self.SetTopWindow(frame_1)
frame_1.Show(1)
frame_1.StartSlave()
return 1

# end of class MyApp

if __name__ == "__main__":
app = MyApp(0)
app.MainLoop()

----------------------------

#!/usr/bin/env python
# Module: tk_slave.py

import sys
import Tkinter
class EmbeddedTk:
"""Create Embedded Tk app inside a wxPython app """

def __init__(self, window_id):
print 'Received window id =', window_id

self.window_id = window_id
self.root = Tkinter.Tk()
self.root.withdraw()

toplevel = Tkinter.Toplevel(use=self.window_id)
#toplevel = Tkinter.Toplevel(self.root)

self.c = Tkinter.Canvas(toplevel, width=250, height=250,
bg='white', bd=0)
self.c.pack()
self.c.create_rectangle(20,20,230,230)
self.root.mainloop()
if __name__ == '__main__':

if len(sys.argv) != 2:
sys.exit('Usage: python tk_slave.py window_id\n')
window_id = sys.argv[1]
EmbeddedTk(window_id)
Jul 18 '05 #1
0 1931

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: omission9 | last post by:
An application I have written is, suddenly it seems, throwing the following error after being left in use for several hours. This does not seem to occur with lighter usage. I am not 100% sure what...
3
by: Tim Williams | last post by:
Hi. I'm starting to learn wxPython and for an exercise I'm writing a simple CSV file viewer. I just read in the CSV file and create a wx.Grid with the data. I'm using Python 2.3.2 with wxPython...
1
by: mitsura | last post by:
Hi, I have a question about wxPython. On Windows systems, you can point your mouse over most items on your desktop and a after a second or so, a small window will pop-up with extra info about...
6
by: zdp | last post by:
Dear all: I made a window program by wxPython. Split windows, treectrl, listctrl and textctrl are used. When I program in python, the look & feel of the window controls are like the windos XP...
0
gundarap
by: gundarap | last post by:
Hello all, I was wondering whether wxpython code can be embedded in HTML code. I saw that We can do the converse i.e., we can write HTML code in wxpython code. Jython is doing this favour with...
0
by: =?ISO-8859-15?Q?J=FCrgen_Kareta?= | last post by:
Hello List, my customer is looking for an application to show some simple 2d graphs based on messured data. I'm consider to use wxpython, matplotlib and py2exe to build and compile this...
1
by: rocksportrocker | last post by:
Hi, I want to visualize some vtk-files within a wxPython Window. Google did not help me very much, I only found some tools for Tk, what is no solution for me. I'm sure I am not the first one...
5
by: Jimmy | last post by:
Hi, all I have been trying to use wxPython to design a GUI that will be displayed on the panel on the top of desktop. that is when the program starts, it will dwell on the panel to display some...
3
by: Leo Lee | last post by:
I need a window's handle to be passed to external c++. Thanks in advance
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.