GUI programming without OOP [closed] - python

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I have a background in structural programming (Pascal,Ada) and now I have been programming an app in Java because I needed to use a given package that was only available for Java,C++ and Python. I chose Java, but I think it was not the best idea as I am not into OOP and I am programming it in a structural way, this is, only with methods and the main program,avoiding to generate objects and those Java things.
Now that I have the "app" running in the windows console I need to generate a GUI to operate it, but before going to hell with Java and objects I would prefer to change to another programming language that permits me to constract the GUI with my structural programming mindset (if it is possible).
I have read that Tkinter in Python and GTkAda in Ada could be my saviours. In case of not being possible I guess I should try to get into OOP.
Thanks in advance

GtkAda is also object-oriented, and so is any other high-level GUI toolkit I've seen so far, so I don't think you can avoid object-oriented programming for the GUI, unless you use a more low-level approach.
Two more low-level approaches are:
An HTTP/HTML based interface.
Using the X protocol to talk directly with an X server.
Both of these approaches can be used with Ada, and probably also with Python. I don't know for sure if Python can do the necessary low-level formatting to talk with an X server, but it must be possible somehow.

If you're looking to use Python, try out PySimpleGUI. There are objects in use, but you don't have to do any object programming. You can copy and paste the "design patterns" without having to know exactly what they do. It was developed with beginners in mind, but can also support advanced, customized window layouts. Look at the Cookbook for code examples. You mostly need to learn how to do a "layout". You will not have to write the word "class" in your code, promise.

Related

What is the purpose of embedding a scripting language into a programming language in a game engine? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm interesting in making games in my future, and I've heard that my favourite game's engine is made with c++, but its embedded with python. I have little experience with programming, but I greatly understand how object orientation works.
Why would someone need/want to embed a scripting language into a programming language?
The main reason obviously is to allow to provide extensions to the game engine without need to recompile the entire game executable program, but have the extensions loaded and interpreted at run time.
Many game engines provide such feature for extensibility.
... but I greatly understand how object orientation works.
Object orientation comes in with the interfaces declared, how to interact with the particular scripts.
So python is itself an object oriented language which supports OOP principles quite well.
For instance integration of non OOP scripting languages, like e.g. lua scripts (also oftenly used for extensions), makes that harder, but not impossible after all.
There are many reasons, but the primary motivations are customization and "playback". By playback, I mean the ability to automate or repeat a series of tasks in the program without requiring programming expertise. Blender is a good example of this.

Is python a good choice to build a desktop application? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'm wondering if python is a good choice to develop a desktop application for a small business.
Is it possible to build something using PyQT or even Swing + Jython ? How I can make a executable file at the end?
I've found Python to be an excellent choice for developing a broad scala of applications including desktop applications. I've developed in C++ for many years, and for parts that are really time critical I sometimes use it still, but for most of my code Python helps me get results much faster. There are several ways to get an executable. Py2exe is one of them, Cython another option allowing easy combination with C++ if you need raw speed, interfacing with 3rd party libaries or low level control of devices. It also makes reverse engineering a bit harder, if that's a concern in your project.
By the way, when I started out with Python I was very concerned about performance and (being a quality manager at that time) almost blocked its introducion in our company for its lack of strickt typing. I was wrong about both. Since especially the rich set of built in datastructures as well as many of its standard modules are written in C++ and have been carefully optimized, it isn't so easy to beat on speed and memory efficiency as one might think. And the dynamic typing (only recently introduced in a language like C#) proved a very powerful means to write concise, readable, reliable and compact code.
I don't have shares (since Python is open source anyhow) but from all the languages I've used in the past (Algol, Pascal, Modula II, Assembler, Basic, Fortran, Cobol, C, C++, C#, Java, JavaScript) it's the one I prefer rightnow to earn a living with.
It depends on what you are looking to do. I have done it and it worked but there are other questions that can factor in like who will maintain or update the code, and do they know Python. You can look at cx_freeze for making a windows executable out of a python program as one of many options.

why do people say that RPython is an unpleasant language to program in [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
It is often stated that RPython is an unpleasant language to program in, for example, here, here, here or here.
However, for example here in the original paper about RPython, it says quite the opposite:
The result is a language that is more expressive than C# and Java, but
which does not compromise runtime efficiency. RPython was initially
designed for the specific purpose of implementing PyPy [25] (a Python
interpreter written in Python), but it has grown into a full-fledged
language in its own right.
Currently, RPython can be used in many contexts: to develop
stand-alone programs, such as the Standard Interpreter itself; to
write highly efficient extension modules for CPython, which could only
be written in C in the past; to develop dynamic web applications
without the need to write JavaScript code; to produce efficient
libraries of classes and functions to be used by other .NET and Java
programs. In particular, RPython can be the ideal companion for all
those CPython, IronPython and Jython developers that so far have been
forced to write the parts of their programs that need high performance
in C, C# or Java.
A related question for using RPython as a general purpose language is also here. I was also wondering about using RPython as a replacement for Cython. A related question is here. There is also the RPythonic project.
Why is it that people recommend against using RPython?
from here:https://mail.python.org/pipermail/pypy-dev/2013-June/011503.html
"
When people look at RPython, an obvious feature is that it is
syntactically identical to Python. "RPython must be an easy language,
given that it has got the syntax of Python, which is easy". This is a
common misconception. In fact, pleasing the automatic type inference
process can be difficult. It requires the programmer keeping in his
head the global types of his whole program, and carefully writing code
according to these implicit types. The process is much harder for
newcomers, which don't have any written-down example to learn how to
manipulate the types --- precisely because they are implicit.
"
I have made one file conversion program using RPython toolchain. Simple buffered file input and output. I can't imagine with my skills easier language to make such a fast, reliable, low bugs program.
What works and what doesn't is not well documented but once you find things out it is really nice set of tools to make small, fast and reliable programs.

I need help in python code analysis [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 months ago.
Improve this question
I have to implement a bioinformatics algorithm on Java over cloud. I have been given Python code for the same. I know Java and Hadoop quite well;
However, I have no knowledge in Python. I am looking for a tool so I can analyze the Python code, understand the algorithm and prepare a pseudo code for implementing it in Java. I already looked for some dependency analyzer; however, it didn't help much.
Is my approach wrong? Do I have to learn Python to do this task?
I am willing to work hard on this project, I need the direction. How should I approach this problem?
If you want to understand a program written in python, you should learn python. This will probably be the easiest way, if there is no other description of the algorithm.
Python is a very easy language to learn, plus you barely will have to learn much to just read an algorithm. Python reads like pseudocode.
The trick is, which version of Python to learn? There are two major versions: Python 2 and Python 3. Code written for Python 2 will probably not run in Python 3 and vice versa. So figure out which one you're dealing with first. Probably the best way to find out is ask the person you got the Python code from.
The official Python tutorials are pretty easy to follow, and I'd recommend you start with those.
Python 2: http://docs.python.org/tutorial/
Python 3: http://docs.python.org/py3k/tutorial/
Don't worry about learning a new language. Python is very easy to learn, and you only need to learn a small part of it. I learned almost all the syntax in an evening.

Python TUI libs [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
The community reviewed whether to reopen this question 7 months ago and left it closed:
Opinion-based Update the question so it can be answered with facts and citations by editing this post.
Improve this question
I'm writing a small sudoku game/solver in Linux using python with TUI (not GUI, that's just lame) just for fun. My question is, which lib is better (by that I mean easier to handle, better support, more straight-forward and understandable), the choices are curses or urwid or if anyone have better suggention, and why? I have some Tkinter and wxPython experiences.
Any help or information will be appreciated.
You might want to check out Unicurses, which wraps the python core curses module in UNIX systems and wraps the free pdcurses library on windows-based machines.
This library is designed to emulate the syntax and style of the original ncurses library, so if you're interested in learning TUI design using curses-style programming, then check it out.
Urwid is, from what little documentation I've read, a very interesting library which uses event loops (the reactor pattern) as a basis for application design, much like tkinter or Twisted. Also, urwid has an event loop class specifically designed for use with Twisted, so if your aim is to created TUIs for use over networks, its a good choice. Twisted also uses the reactor pattern, so if you want to learn that style, I'd recommend it.
Finally, if you do go with an ncurses-style library, check out Dan Gookin's book on ncurses. A very good resource, and the only one I know of which is in print today.
There are other options such as newt, pygcurses, and so on, but this should get you started. Best of luck, TUI programming today is one of those technological fetishes that can be hard to break into, but it's rewarding.
While the above is a perfectly reasonable solution for Linux, The OP asked for other suggestions and a justification for them.
Who wants to use a low level API like curses in a modern OO language like Python? Let alone if you are stuck inside Windows (which the OP isn't, but is a problem for a lot of people out there)... There must be a better way.
To try to resolve this, I have put together a simple cross platform class (yup - Windows is included without falling back to PDcurses) to do all the things most people want from their terminal/console. If you're on Linux this is a more human way to program curses. If you're on Windows, the same class works as is with no external binary dependencies. You can find the Screen class in asciimatics.
In addition, I've created a load of highr level objects to create animations and TUIs. For example, this is a recording of a sample using the TUI widgets:
If there's an extra feature you need, let me know and I'll see what I can do.
If your game will run inside a console, then just pick curses.
If your game will run as a GUI application, then just pick PySide.

Categories