progress with gui

This commit is contained in:
koraynilay 2021-01-29 22:22:08 +01:00
parent 35de82485a
commit 5055fdff80

View file

@ -1,20 +1,44 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import gi import gi
import webbrowser
gi.require_version('Gtk', '3.0') gi.require_version('Gtk', '3.0')
from gi.repository import Gtk from gi.repository import Gtk
from legendary.cli import LegendaryCLI
win = Gtk.Window() class MyWindow(Gtk.Window):
grid = Gtk.Grid() def __init__(self):
win.add(grid) Gtk.Window.__init__(self,title="Legendary")
quit = Gtk.Button(label="Quit") self.button = Gtk.Button(label="Login")
quit.set_size_request(80,30) self.button.connect("clicked", self.onclick)
quit.connect("clicked", Gtk.main_quit) self.add(self.button)
def onclick(self, widget):
# webbrowser.open('https://www.epicgames.com/id/login?redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Fid%2Fapi%2Fredirect')
sid = AskSid(self)
print(f'LegendaryCLI.auth(f"--sid {sid}")')
grid.attach(quit,0,0,1,1) def AskSid(parent):
win.set_border_width(10) dialog = Gtk.MessageDialog(parent, Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK_CANCEL)
win.set_title("Legendary") dialog.set_title("Enter Sid")
win.set_wmclass("Legendary","Legendary") #dialog.set_default_size(200, 200)
label = Gtk.Label()
label.set_markup("Please login via the epic web login, if web page did not open automatically, please manually open the following URL:\n<a href=\"https://www.epicgames.com/id/login?redirectUrl=https://www.epicgames.com/id/api/redirect\">https://www.epicgames.com/id/login?redirectUrl=https://www.epicgames.com/id/api/redirect</a>")
entry = Gtk.Entry()
box = dialog.get_content_area()
box.pack_start(label, False, False, 0)
box.add(entry)
dialog.show_all()
response = dialog.run()
sid = entry.get_text()
dialog.destroy()
if response == Gtk.ResponseType.OK:
return sid
else:
return 1
win = MyWindow()
win.connect("destroy", Gtk.main_quit) win.connect("destroy", Gtk.main_quit)
win.show() win.show_all()
Gtk.main() Gtk.main()