Swee (Licorice)
4233c29d58
All checks were successful
Sanity check / Test Python file (push) Successful in 9s
29 lines
1.3 KiB
Python
29 lines
1.3 KiB
Python
import gi, os, sys, sweecrypt as sc
|
|
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 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")
|
|
shift = int(self.builder.get_object('shift').get_property("value"))
|
|
inputted = self.builder.get_object('text').get_property("text")
|
|
if encode:
|
|
self.builder.get_object('text').set_property("text", sc.encrypt(inputted, shift))
|
|
self.builder.get_object('encode').set_property("active", False)
|
|
else:
|
|
self.builder.get_object('text').set_property("text", sc.decrypt(inputted, shift))
|
|
self.builder.get_object('encode').set_property("active", True)
|
|
def main():
|
|
app = GUI()
|
|
Gtk.main()
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|