I use python for various personal projects and hobby stuff. I do mostly command line stuff, just cuz I don't need the gui for a lot of it.

I would like to start moving on to GUIs, but I have run into a problem. I started with Python v3. All the toolkits, WYSIWYG designers, etc are all for version 2.

Is there a toolkit and (hopefully) a WYSIWYG designer for Python 3?

Recommended Answers

All 6 Replies

You cannot distribute Qt software on Windows without a license.

You cannot distribute Qt software on Windows without a license.

Really meant for commercial software only.

The problem with designer programs is that they create rather bloated code.

Most seasoned GUI programmers prefer a template approach. The Tkinter GUI toolkit has been updated with the release of Python version 3.1 and now contains the extra widgets that come with the tile extension ttk.

I've never really done GUIs in python. I usually use C# .NET for GUI projects. What do you mean by a template approach? Most of my programming experience is command line based with C++ and Python.

For instance, if you had to write a program that asks for two values from the user to solve a mathematical equation, you could adopt this Tkinter program as a basic template. Simply change some of the text and the equation and you are done ...

# tk_template_2entry_3label_1button1.py
# a Tkinter template to solve a mathematical equation
# requesting two values from the user
# uses 2 Entry widgets, 3 Label widgets and 1 Button widget

try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

def calculate():
    """ calculate the resistance of two resistors in parallel """
    try:
        r1 = float(enter1.get())
        r2 = float(enter2.get())
        if r1 + r2 > 0:
            rp = (r1 * r2) / (r1 + r2)
            label3.config(text='Parallel resistance = ' + str(rp))
        else:
            label3.config(text='division by zero error')
    except ValueError:
        label3.config(text='Enter numeric values for r1 and r2')

def setfocus2(event):
    enter2.focus_set()

        
# create root window
root = tk.Tk()

# create all the components
label1 = tk.Label(root, text='Enter value of resistor1:', width=28)
enter1 = tk.Entry(root, bg='yellow')
label2 = tk.Label(root, text='Enter value of resistor2:')
enter2 = tk.Entry(root, bg='yellow')
btn1 = tk.Button(root, text='Calculate', command=calculate)
label3 = tk.Label(root, text='', bg='green')
# pack the root window in that order
label1.pack(side='top', fill='x')
enter1.pack(side='top', fill='x')
label2.pack(side='top', fill='x')
enter2.pack(side='top', fill='x')
btn1.pack(side='top')
label3.pack(side='top', fill='x')

# cursor in enter1
enter1.focus()
# return key in enter1 sets focus to enter2
enter1.bind("<Return>", func=setfocus2)

# start event loop and program
root.mainloop()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.