GUI programming in Python using Appjar

Overview

Create a Python application with a GUI using TKinter's wrapper called Appjar.

environment

OS: Windows10 Python: 2.7.15

Installation

pip install appjar

How to use

The basic flow is as follows. ① Library import ② Create GUI instance (base) ③ Add widget ④ Create a corresponding function for the widget that generates an event such as Button. ⑤ Start GUI

See Official for more information. The following is a slight modification of the official Hello World.

SimpleGUI.py


# -*- coding: utf-8 -*-

#① Import library
from appJar import gui

#② Create a GUI instance
#Format: app = gui("Window name","vertical x width")
app = gui("Login Window", "400x200")

#Specifying the overall background color, text color and font
app.setBg("black")
app.setFg("white")
app.setFont(16)

#(3) Define a function to link with the event on the GUI
def press(button):
    if button == "Cancel":
        app.stop()
    else:
        usr = app.getEntry("Username")
        pwd = app.getEntry("Password")
        print("User:", usr, "Pass:", pwd)
        
#④ Add widgets to the base instance.
app.addLabel("title", "Welcome to appJar")
app.setLabelBg("title", "lightblue")
app.setLabelFg("title", "black")

app.addLabelEntry("Username")
app.addLabelSecretEntry("Password")

# "Submit","Cancel"Create two buttons, and specify the press function as the corresponding action.
app.addButtons(["Submit", "Cancel"], press)

# "Username"Set focus on
app.setFocus("Username")

#⑤ Start GUI. Basically, do not write any code after this.
app.go()

As a rough reminder, the attributes of gui () are (add or set) + (widget name) + (parameter name) The argument is ("Attribute name", "Parameter value") It seems that it is. In add, the parameter part may be only the argument part. For example, app.setLabelBg ("title", "lightblue") The value of the Bg parameter of the Label widget named title, It is in the form of being changed (set) to the value lightblue.

Supplement

List of available widgets http://appjar.info/pythonWidgets/ However, here are just some of the parameters that can be changed for each widget. For example, if you look only here, you can't set the background for Message, but that's not the case, and the basic parameters (Bg, Fg, Width, etc.) are the same. See here for more details on the configurable parameters.

Summary

I personally think Appjar is more intuitive and straightforward than TKinter. However, it was a little difficult to understand the layout of the documents, so I feel that the hurdle to start using is a little high. I hope this article helps you.

Recommended Posts

GUI programming in Python using Appjar
Programming in python
GUI creation in python using tkinter 2
GUI creation in python using tkinter part 1
[GUI in Python] PyQt5-Dialog-
Python programming in Excel
[GUI in Python] PyQt5 -Widget-
Introducing GUI: PyQt5 in Python
[GUI in Python] PyQt5 -Event-
Translate using googletrans in Python
Using Python mode in Processing
Try to make it using GUI and PyQt in Python
Functional programming in Python Project Euler 1
Precautions when using pit in Python
Create a python GUI using tkinter
Functional programming in Python Project Euler 3
Try using LevelDB in Python (plyvel)
Using global variables in python functions
Let's see using input in python
Infinite product in Python (using functools)
Edit videos in Python using MoviePy
Functional programming in Python Project Euler 2
[GUI in Python] PyQt5-Menu and Toolbar-
Handwriting recognition using KNN in Python
Try using Leap Motion in Python
Depth-first search using stack in Python
When using regular expressions in Python
Mouse operation using Windows API in Python
Notes using cChardet and python3-chardet in Python 3.3.1.
About building GUI using TKinter of Python
Try using the Wunderlist API in Python
Get Suica balance in Python (using libpafe)
(Bad) practice of using this in Python
Slowly hash passwords using bcrypt in Python
Try using the Kraken API in Python
Using venv in Windows + Docker environment [Python]
Create a simple GUI app in Python
[FX] Hit oanda-API in Python using Docker
Tweet using the Twitter API in Python
[Python] [Windows] Serial communication in Python using DLL
I tried using Bayesian Optimization in Python
GUI programming using kivy ~ Part 6 Various layouts ~
Log in to Slack using requests in Python
Get Youtube data in Python using Youtube Data API
Using physical constants in Python scipy.constants ~ constants e ~
Scraping a website using JavaScript in Python
Develop slack bot in python using chat.postMessage
Scientific Programming Petit Tech Collection in Python
Write python modules in fortran using f2py
Draw a tree in Python 3 using graphviz
GUI programming using kivy ~ Part 2 Progress bar ~
Notes for using python (pydev) in eclipse
Disease classification in Random Forest using Python
Try a functional programming pipe in Python
Download files in any format using Python
Parallel task execution using concurrent.futures in Python
Learn dynamic programming in Python (A ~ E)
Notes on using code formatter in Python
GUI display train delay information using python
Meaning of using DI framework in Python
Quadtree in Python --2