Playing around with tkinter

A nice tool I’ve found recently using python and tkinter is pygubu-designer. (used for a playing around with python project – https://github.com/zelle7/websocketocppgui)

A typical gui, even the simple ones like those which are build with tkinter come to a point where it become quite cumbersome generating all the variables and/or properties which define the elements in the gui. At least for me, it is getting confusing quite fast and you have a lot of starting and stopping the application, to see if your updates have been successful. The pygubu-designer comes with some a simple gui which allows you to drag in th elements you need. In addition to that you can configure various things (from visual stuff up to click handler functions).

You can install the package via pip(package pygubu https://pypi.org/project/pygubu/ ), and start in the commandline with pygubu-designer.The gui looks like this:

The left part is the configuration part and the right things you see is a preview of the app and how it will look like. The tool itself is generating an ui-file which is just a file with xml content.

One thing which was a little bit confusing at the beginning: There is no way to just drop existing elements into others. e.g. drag an existing label into a frame. As a workaround you can cut the elements and paste them into the wanted containers. Another thing is that you can move elements up, down, left, right with ALT + (I|K|J|L).

Maven Basis Struktur für ein Executable Jar File mit Dependencies

Um ein executeble jar File mit maven zu erstellen, wird folgendes xml benötigt.


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>lire9gag</groupId>
    <artifactId>at.rumpelcoders.lire9gag</artifactId>
    <version>1.0-SNAPSHOT</version>

    <!-- Output to jar format -->
    <packaging>jar</packaging>

    <properties>
        <jdk.version>1.8</jdk.version>
        <junit.version>4.11</junit.version>
        <log4j.version>1.2.17</log4j.version>
        <maven.compiler.plugin.version>3.1</maven.compiler.plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>lire9gag</finalName>
        <plugins>
            <!-- Set a JDK compiler level -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                </configuration>
            </plugin>

            <!-- Make this jar executable -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <!-- comment in to DO NOT include log4j.properties file in your Jar
                    <excludes>
                        <exclude>**/log4j.properties</exclude>
                    </excludes>
                    -->
                    <archive>
                        <manifest>
                            <!-- Jar file entry point -->
                            <mainClass>at.rumpelcoders.lire9gag.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>

Es wurde hier zusätzlich log4j und junit eingefügt da diese oft gebraucht werden.

Sollte folgender Fehler auftreten:


[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Fatal error compiling

Embedded error: invalid target release: 1.8
[INFO] ------------------------------------------------------------------------
Selection_008
Prüft die JAVA_HOME Variable [code]echo $JAVA_HOME[/code] auf die entsprechende Java Version eingestellt ist.

Das jar-File kann anschließend unter „target/groupId.jar“ gefunden werden

Hilfreiche Links:

Scroll to top