From 27f760cb7962f76842ae810104eaea10ec1d422a Mon Sep 17 00:00:00 2001 From: "Swee (Licorice)" Date: Mon, 23 Dec 2024 15:15:06 -0800 Subject: [PATCH] UI refresh --- sweecrypt-gtk.py | 49 ++++++++++++---------------- sweecrypt-gtk.ui | 84 ++++++++++++++++++------------------------------ 2 files changed, 53 insertions(+), 80 deletions(-) diff --git a/sweecrypt-gtk.py b/sweecrypt-gtk.py index b55de73..cd21950 100644 --- a/sweecrypt-gtk.py +++ b/sweecrypt-gtk.py @@ -3,33 +3,26 @@ gi.require_version("Gtk", "3.0") from gi.repository import Gtk, GdkPixbuf, Gdk 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 toggle(self, e:bool): - if e: - active = self.builder.get_object('encode').get_property("active") - self.builder.get_object('decode').set_property("active", not active) - else: - active = self.builder.get_object('decode').get_property("active") - self.builder.get_object('encode').set_property("active", not active) - def on_window_destroy(self, window):Gtk.main_quit() - def encode_toggle(self, encode):self.toggle(True) - def decode_toggle(self, decode):self.toggle(False) - def start_clicked(self, start): - 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", sc.encrypt(inputted)) - self.builder.get_object('encode').set_property("active", False) - else: - self.builder.get_object('text').set_property("text", sc.decrypt(inputted)) - self.builder.get_object('decode').set_property("active", False) + 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 toggle(self, checkbox): + checkbox.set_property("label", "Encode" if checkbox.get_property("active") else "Decode") + def start_clicked(self, start): + 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", sc.encrypt(inputted)) + self.builder.get_object('encode').set_property("active", False) + else: + self.builder.get_object('text').set_property("text", sc.decrypt(inputted)) + self.builder.get_object('encode').set_property("active", True) def main(): - app = GUI() - Gtk.main() + app = GUI() + Gtk.main() if __name__ == "__main__": - sys.exit(main()) \ No newline at end of file + sys.exit(main()) diff --git a/sweecrypt-gtk.ui b/sweecrypt-gtk.ui index 48d1b12..a1703bf 100644 --- a/sweecrypt-gtk.ui +++ b/sweecrypt-gtk.ui @@ -2,21 +2,6 @@ - - True - False - edit-copy - - - True - False - document-revert - - - True - False - document-properties - replace this text with anything you want to encode or decode. @@ -54,29 +39,39 @@ you want to encode or decode. - - Encode + True - True - True - image1 - True - - - - False - True - 1 - - - - - Decode - True - True - True - image2 - + False + + + Encode + True + True + True + True + + + + False + True + 1 + + + + + Start + True + True + True + + + + False + True + end + 2 + + False @@ -84,21 +79,6 @@ you want to encode or decode. 2 - - - Start - True - True - True - start - - - - False - True - 4 - -