from gi.repository import Gtk, GdkPixbuf, Gdk import os, sys from sweecrypt import encrypt, decrypt UI_FILE = os.path.dirname(os.path.realpath(__file__)) + "/sweecrypt-gtk.ui" class GUI: def __init__(self): self.builder = Gtk.Builder() self.builder.add_from_file(UI_FILE) self.builder.connect_signals(self) window = self.builder.get_object('window') window.show_all() def on_window_destroy(self, window): Gtk.main_quit() def encode_toggle(self, encode): active = encode.get_property("active") print(f"Encode = {active}") self.builder.get_object('decode').set_property("active", not active) def decode_toggle(self, decode): active = decode.get_property("active") print(f"Decode = {active}") self.builder.get_object('encode').set_property("active", not active) def start_clicked(self, start): print("Start clicked!") encode = self.builder.get_object('encode').get_property("active") inputted = self.builder.get_object('text').get_property("text") if encode: self.builder.get_object('text').set_property("text", encrypt(inputted)) self.builder.get_object('encode').set_property("active", False) else: self.builder.get_object('text').set_property("text", decrypt(inputted)) self.builder.get_object('decode').set_property("active", False) def main(): app = GUI() Gtk.main() if __name__ == "__main__": sys.exit(main())