sweeCrypt-GTK/sweecrypt-gtk.py

37 lines
1.4 KiB
Python
Raw Normal View History

import gi
gi.require_version("Gtk", "3.0")
2024-09-07 19:39:45 -07:00
from gi.repository import Gtk, GdkPixbuf, Gdk
import os, sys
2024-09-07 21:09:23 -07:00
from sweecrypt import encrypt, decrypt
2024-09-07 19:39:45 -07:00
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()
2024-09-09 16:27:59 -07:00
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)
2024-09-07 21:09:23 -07:00
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", 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)
2024-09-07 19:39:45 -07:00
def main():
app = GUI()
Gtk.main()
if __name__ == "__main__":
2024-09-07 21:09:23 -07:00
sys.exit(main())