sweeCrypt-GTK/sweecrypt-gtk.py

30 lines
1.3 KiB
Python
Raw Permalink Normal View History

2024-09-09 16:47:18 -07:00
import gi, os, sys, sweecrypt as sc
gi.require_version("Gtk", "3.0")
2024-09-07 19:39:45 -07:00
from gi.repository import Gtk, GdkPixbuf, Gdk
UI_FILE = os.path.dirname(os.path.realpath(__file__)) + "/sweecrypt-gtk.ui"
class GUI:
2024-12-23 15:15:06 -08:00
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")
2024-12-24 16:29:10 -08:00
shift = int(self.builder.get_object('shift').get_property("value"))
2024-12-23 15:15:06 -08:00
inputted = self.builder.get_object('text').get_property("text")
if encode:
2024-12-24 16:29:10 -08:00
self.builder.get_object('text').set_property("text", sc.encrypt(inputted, shift))
2024-12-23 15:15:06 -08:00
self.builder.get_object('encode').set_property("active", False)
else:
2024-12-24 16:29:10 -08:00
self.builder.get_object('text').set_property("text", sc.decrypt(inputted, shift))
2024-12-23 15:15:06 -08:00
self.builder.get_object('encode').set_property("active", True)
2024-09-07 19:39:45 -07:00
def main():
2024-12-23 15:15:06 -08:00
app = GUI()
Gtk.main()
2024-09-07 19:39:45 -07:00
if __name__ == "__main__":
2024-12-23 15:15:06 -08:00
sys.exit(main())