- Is it possible to create a user interface without the help of python framework (like tinker or pygame) and use only vanilla python code? If yes, how?
- Can you briefly explain how python framework works?
- Is the code of different python framework different?
- If the computer did not have the framework installed, will the program still runnable if the program uses a framework? Thanks very much
-
3Curious as to why you would need to do this, as the docs say: "The Tkinter module (“Tk interface”) is the standard Python interface to the Tk GUI toolkit. Both Tk and Tkinter are available on most Unix platforms, as well as on Windows systems"kezzos– kezzos2016-09-23 07:25:52 +00:00Commented Sep 23, 2016 at 7:25
-
1Note that you should ask separate questions, and each is way too broad. In short: 1) Yes, but it depends on the target system and restriction on "vanilla python code" - tkinter is part of the standard library. 2) No, depends on which one you mean. 3) Yes, that's why they are different frameworks. 4) Only if you install the framework.MisterMiyagi– MisterMiyagi2016-09-23 07:56:20 +00:00Commented Sep 23, 2016 at 7:56
Add a comment
|
2 Answers
- Yes, after all tinker and pygame are just python classes packaged as modules.
- Python frameworks are a bunch of pre-tested and reusable modules that allow you to use and extend upon so you don't have to reinvent the wheel.
- Yes, frameworks will have differences in usability and code.
- The computer will always need the dependencies, though you can package these in various ways aka create a package that has all your dependencies for the program to run.
1 Comment
Matthias Schreiber
I would just add to 1., that it is possible without such frameworks by using things like OpenGL directly. In a sense, the frameworks just create a nice layer around it to make it easier to access and depending on the framework size, build upon it by adding widgets and functionality.
If you want as few external dependencies as possible (but still a GUI) I would strongly suggest using a Web-Microframework like bottle (single file) and utilize the user's browser for rendering.
- You can make a GUI without any external framework with HTML by setting up a webserver and using the user's browser to render it.
- For a browser-GUI without an external Framework: Depending on whether you know JavaScript you can either use XML-RPC (xmlrpc.server+http.server with JS in the browser) or WSGI (wsgiref) (example on that page)
- Yes, totally.
- Of course the if you do not prepare for this case you cannot run a program without an integral part of it like a Framework - but you can distribute your program with the Framework included.
For XML-RPC
import xmlrpc.server
import http.server
class MyHandler(xmlrpc.server.SimpleXMLRPCRequestHandler,http.server.SimpleHTTPRequestHandler):
pass
This handler will serve files from the current working directory (your actual HTML-UI and JS for communication (there are several XMP-RPC libraries for JS)) but it can also be used like in the XML-RPC-Server example to glue your code and the UI together.