1

I've a Tkinter based UI and I would like to show a Gantt Chart that is made in Jython (using swings)

The thing is that I dont want to have two different windows, one for the Tkinter UI, and other one for the Jython's Gantt Chart.

Is there a way to put both things in one window?

Thanks in advance.

Avión
  • 7,963
  • 11
  • 64
  • 105

1 Answers1

1

I feel your pain, however GUI toolkits manage their own windows and most of the time it is not possible to share or embed windows without using OS specific native APIs.

You could create an applet to show your swing window in a box / rectangle but Tkinter does not ship with a widget that can display webpages or applets. The reverse process is technically possible but I haven't seen any real-world practical examples.

If functionality is not required, your best bet is to capture the output of the window (Java example: Swing: Obtain Image of JFrame) and display your graph on Tkinter with

import Image, ImageTk

im = Image.open('file_name').convert2byte()
tkimage = ImageTk.PhotoImage(im)

Tkinter.Label(root, image=tkimage).pack() 

On a side note:

It is kind of possible to access the toolkits in a reverse way with Jpype and Jtkinter but the difference between Tcl based Tkinter and Swing is still great and it will still not solve this problem.

Community
  • 1
  • 1
Furkan Omay
  • 1,047
  • 1
  • 11
  • 22
  • Yeah, I also thought about the easy solution of saving it as a image and load easily in Tkinter, but this is unuseful for me, as the Gantt charts need real time manipulation. – Avión Feb 27 '14 at 18:46
  • Since you are using already two different gui toolkits, I didn't want to introduce a third layer but some libraries can dock (embed) two different processes' windows' into one window, maybe you can try that if you really want to achieve this. It's generally used for games though, they launch the process with subprocess(), then use SDL (or PyGame) to capture the window. SDL / PyGame surface can be embedded into Tkinter. But imho this is somewhat overkill. – Furkan Omay Feb 27 '14 at 21:02