Hi all,
Long time lurker, first time poster.
The subject says it all. I hate duplicating work, or wasting my time on something that is a dead end. I've done my research, and I can't seem to find a Tcl/Tk JavaScript port, nor can I find a full UI for Brython, so I'm asking for opinion.
I see CodeSkulptor has ported the python package simplegui to it's site, and from the chatter on this group, I believe it's a javascript lib, but there may be license issues with it's reuse.
I would need a fairly full GUI for a web app, one that is licensed BSD/Python, not GPL.
I've already managed to port enough of tkinter last night that this simple tkinter intro script runs in Brython:
import tkinter
def stopProg(e):
root.destroy()
root = tkinter.Tk()
print("attempting Button")
button1=tkinter.Button(root, text="Hello World click to close")
button1.pack()
button1.bind('<Button-1>',stopProg)
root.mainloop()
I reference the code in _tkinter.c to ensure I'm making a compatible port. That was a great way to get my feet wet with my first Brython experience, but I want to pause and see what others think.
Some Background:
I haven't worked with Tkinter before. When I've needed to make a Python desktop GUI in the past, I went with Qt, as I have experience with Qt from C programming days.
My last big JavaScript UI was with Dojo Toolkit, so I have a fair amount of experience there, and I must say Dojo is a great option if you're in the JavaScript world. AMD modules make it worth the price of admission, but the price of admission is oh so high.. much of the learning is through hard work.
My current requirements at work have me dusting off a Dojo prototype, and developing it into a full product - And I'm going to spend a few days checking if it could be viable to do this in Brython instead.
I have a desire to stay inside of Python as much as possible, particularly after my last experience. The last few weeks found me porting an old hacky, massive Unix C prog to Windows. While I've been programming C since the 80's, I haven't had need to do much C for the last 4 years as I've been purely Python. Getting back into C after years of Python reminded me how much time is wasted dealing with language and compiler cruft, rather than developing the application.
Javascript is better then C, but still has a lot of issues, and by all means, scales into a ugly mess by the time you've created a complex app. I want real classes and inheritance, and in general the syntax of Python.
I have considered wrapping Dojo for Brython, but Dojo is a full framework that wraps it's Widgets (called Dijits in Dojo). With Brython, I wouldn't need the Dojo framework.
Brython does poke along a bit slower than I like, but I view that as a temporary problem, one that I may be able to help with if I'm in Brython regularly for my webgui work. Dojo is not a speedy framework either, so I'm not giving up a lot by switching.
So: Since Tkinter seems to be the ugly child of Python, I looked at wxPython, and Qt - Both would have license issues with a port I feel, not to mention that they are quite large, even if only a subset is ported. Perhaps I'm wrokn? I keep coming back to Tkinter as the best choice for GUI porting.
Tkinter has the advantage of being the default GUI for Windows Python, so porting it to Brython means that some/most of the Tkinter apps in Python would then port to Brython easily - I think that's a worthy goal. I also think that there must be some pythonic logic for Tkinter that I'm just not seeing - Or perhaps was it the easiest way to gain some cross platform UI ability?
Additionally, a compatible Brython Tkinter module would make it easy to develop an application locally in Tkinter, offline with the full support of an IDE / Debugger to step through Python logic issues. Staying inside of a local IDE does give you speed advantages as opposed to working in a browser.
Tk is the graphic layer that sits on top of Tcl. Tcl is it's own scripting language by itself, and I have no interests in porting a full Tcl reference as well. This is one area where my lack of experience with Tkinter makes me unsure - Will I need most of Tcl to make this work?
My plan would be that my Tkinter port would be calling to Javascript directly for it's graphic primitives (HTML5 as much as I can), and this wouldn't need TCL. This should keep complexity down, and keep UI speed up. While I want to remain in Brython as much as possible, I have little problem with optimizing libraries in a different language - All of Python's speed intensive modules are written in C. I want my application to be Python, the libs can be whatever as long as I have Python compatibility.
I would then port/wrap a few key widgets, like GridX, as that's beyond my desire to recreate from scratch - Possibly pull in any license-compatible JQuery bits that would flesh out the UI. I do have to get back to productive commercial output relatively fast, so this all works if there is an overall savings of time for my project due to being in Python not Dojo, otherwise I should be coding in Dojo right now.
I think that's plenty for a first message, and you can see I've put some thought into this - I await your posts of "here's the URL to the exact library you described". :-)
Thanks for your comments.