-
Notifications
You must be signed in to change notification settings - Fork 1
/
lunlumo.py
2048 lines (1795 loc) · 98.2 KB
/
lunlumo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# lunlumo.py splits files into QR code loops for file transfer
# Copyright (C) 2017-2018 u/NASA_Welder
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function
import sys
if sys.version_info < (3,):
import Tkinter as tk
def b(x):
return x
else:
import tkinter as tk
import tkinter
import tkinter.ttk as ttk
import tkinter.ttk
import tkinter.filedialog as FileDialog
import tkinter.messagebox as MessageBox
import tkinter.simpledialog as SimpleDialog
#import codecs
def b(x):
#return codeqcs.latin_1_encode(x)[0]
return x.decode("utf-8")
## lunlumo libraries
import wallet_expect as wex
from scanner import Payload
import pyqrcode # external but copy comes with lunlumo
## external libraries
import zlib
from PIL import Image, ImageTk
##
## python stdlib
from math import ceil
import base64
import argparse
import hashlib
import math
import time
import os
import os.path
import re
#import Tkinter as tk
from glob import glob
import webbrowser as web
##
# Monero donations to nasaWelder (babysitting money, so I can code!)
# 48Zuamrb7P5NiBHrSN4ua3JXRZyPt6XTzWLawzK9QKjTVfsc2bUr1UmYJ44sisanuCJzjBAccozckVuTLnHG24ce42Qyak6
class Lunlumo(ttk.Frame):
def __init__(self,app, parent,settings = {},walletFile = None, password = '',background ="misc/genericspace2.gif",daemonAddress = None, daemonHost = None,testnet = False,cold = True,cmd = "./monero-wallet-cli",camera_choice = None,light = False, *args, **kwargs):
ttk.Frame.__init__(self, parent,style = "app.TFrame", *args, **kwargs)
self.app = app
self.parent = parent
self.busy = False
self.cancel = False
self.cold = cold
self.light = light
self.settings = settings
self.background = background
if "monero-wallet-cli" in os.path.basename(cmd):
self.coin = "monero"
self.address_length = 95
self.logo_path = "misc/reddit_user_philkode_made_this.gif"
elif "aeon-wallet-cli" in os.path.basename(cmd):
self.coin = "aeon"
self.address_length = 97
self.logo_path = "misc/aeon_logo2.gif"
else:
raise Exception("Unknown coin %s" % os.path.basename(cmd))
self.wallet = wex.Wallet(walletFile, password,daemonAddress, daemonHost,testnet,self.cold,gui=self,postHydra = True,debug = 5,cmd = cmd,coin = self.coin)
if camera_choice == "webcam (v4l)":
from scanner import Scanner_pygame
self.scanner = Scanner_pygame(app = self)
elif camera_choice == "raspi cam":
from scanner import Scanner_picamera
self.scanner = Scanner_picamera(app = self)
else:
self.scanner = None
self.preview = None
self.initAddress = re.findall(self.wallet.patterns["address"],self.wallet.boot)[0]
self.address_book_menu = None
self.subaddress_book_menu = None
self.account_menu = ["0 %s Primary account (loading tag)" % self.initAddress[:6]]
self.primary_account = self.account_menu[0]
self.earliestBalance = 1000
self.save_settings()
if True: #self.light: #light mode solved by removing imagesfrom backgrounds...
self.full_start()
else:
self.coldsignpage = Coldsign(self,self)
self.coldsignpage.grid(row=0,column = 1 ,sticky=tk.NW+tk.SE,padx=(20,20),pady=(20,20))
def full_start(self):
self.bg = tk.PhotoImage(file = "misc/genericspace2.gif")
self.bg1 = tk.PhotoImage(file = "misc/genericspace.gif")
self.bg3 = tk.PhotoImage(file = "misc/genericspace3.gif")
self.bgv = tk.PhotoImage(file = "misc/genericspacev.gif")
if self.background and not self.light:
self.bglabel = tk.Label(self, image=self.bg)
self.bglabel.place(x=0, y=0, relwidth=1, relheight=1)
try:
self.sidebar = Sidebar(self,self)
self.statusbar = Statusbar(self,self)
self.receivepage = Receive(self,self,background = self.background )
self.donatepage = Donate(self,self)
if not self.cold:
self.sendpage = SendPane(self,self,background = self.background )
self.sendpage.grid(row=0,column = 1 ,sticky=tk.NW+tk.SE,padx=(20,20),pady=(20,20))
else:
self.coldsignpage = Coldsign(self,self)
self.coldsignpage.grid(row=0,column = 1 ,sticky=tk.NW+tk.SE,padx=(20,20),pady=(20,20))
self.sidebar.grid(row=0,column = 0,sticky=tk.NW)
self.statusbar.grid(row=2,column = 0, columnspan =3,sticky=tk.W+tk.E)
self.receivepage.grid(row=0,column = 1 ,sticky=tk.NW+tk.E,padx=(20,20),pady=(20,20))
self.donatepage.grid(row=0,column = 1 ,sticky=tk.NW+tk.E,padx=(20,20),pady=(20,20))
#self._root().after(100,self.receivepage.grid_propagate,False)
except Exception as e:
self.wallet.stopWallet()
MessageBox.showerror("Startup Error",str(e))
raise
self._root().after(1000,self.receivepage.idle_refresh)
self._root().after(2000,self.statusbar.idle_refresh,False)
if not self.cold:
self._root().after(3000,self.sidebar.refresh_account,True,None)
self._root().after(4000,self.sendpage.idle_refresh)
else:
self._root().after(1500,self.sidebar.refresh_account,True,None)
#self._root().after(10000,self.preview_request)
def confirm(self,msg):
return MessageBox.askokcancel("Please Confirm!",msg)
def wallet_alarm(self,err):
MessageBox.showerror("Wallet Error",err)
self.cancel = True
self.preview_cancel()
def showinfo(self,msg):
MessageBox.showinfo("fyi", msg)
def showerror(self,title,err):
MessageBox.showerror(title,err)
def preview_request(self):
if not self.scanner is None:
if not self.preview:
self.preview = Preview(self,self)
self.scanner.add_child(self.preview)
else:
self.showerror("Camera Missing","Unable to display feed, as camera not initialized. This should should have been prevented by upstream logic.")
def preview_cancel(self):
if self.preview:
self.scanner.children.remove(self.preview)
self.preview.close()
self.preview = None
def monitor_incoming(self,payload,when_finished,*args,**kwargs):
if not payload.got_all():
self._root().after(2000,self.monitor_incoming,payload,when_finished,*args,**kwargs)
else:
self.scanner.children.remove(payload)
self._root().after(50,when_finished,payload,*args,**kwargs)
def payload_started(self):
try:
self.sender.destroy()
except Exception as e:
print(str(e))
self.sender = None
def save_settings(self):
try:
with open(".settings","w") as s:
json.dump(self.settings,s,indent=3)
except Exception as e:
print("WARNING: unable to save settings:\n" + str(e))
raise
class Sidebar(ttk.Frame):
def __init__(self,app, parent, delay = 40000,background = "misc/genericspace3.gif", *args, **kwargs):
ttk.Frame.__init__(self, parent,style = "app.TFrame", *args, **kwargs)
self.app = app
self.parent = parent
self.delay = delay
self.bg3 = tk.PhotoImage(file = "misc/genericspace3.gif")
self.bg1 = tk.PhotoImage(file = "misc/genericspace.gif")
self.bg2 = tk.PhotoImage(file = "misc/genericspace2.gif")
self.bgv = tk.PhotoImage(file = "misc/genericspacev.gif")
if background and not self.app.light:
self.bglabel = tk.Label(self, image=self.bg3)
self.bglabel.place(x=0, y=0, relwidth=1, relheight=1)
self.logo = tk.PhotoImage(file = self.app.logo_path)
self.showLogo = ttk.Label(self,image= self.logo)
self.balFrame = tk.Frame(self,highlightcolor = "white",highlightbackground = "white",highlightthickness=3,background ="black",)#"#4C4C4C")
if background and not self.app.light:
self.balbg = tk.PhotoImage(file = background)
self.balbglabel = tk.Label(self.balFrame, image=self.balbg)
self.balbglabel.place(x=0, y=0, relwidth=1, relheight=1)
initBal = self.app.wallet.patterns["balance"].search(self.app.wallet.boot)
if not initBal:
initBal = ("X.XXXXXXXXXXXX","X.XXXXXXXXXXXX")
self._root().after(self.app.earliestBalance,self.idle_refresh)
else:
try:
initBal = (initBal.group("balance"),initBal.group("unlocked"))
except:
initBal = ("X.XXXXXXXXXXXX","X.XXXXXXXXXXXX")
self._root().after(25000,self.idle_refresh)
self.account_picker = MyWidget(self.app,self.balFrame,handle = "Account",cwidth = 21,
choices = self.app.account_menu,startVal = self.app.primary_account,cmd = self.account_chosen)
self.balLabel = ttk.Label(self.balFrame,text = "Balance:",style = "app.TLabel",)
self.balance = ttk.Label(self.balFrame,text = initBal[0],style = "app.TLabel",)
self.unlockedLabel =ttk.Label(self.balFrame,text = "Unlocked:",style = "unlocked.TLabel",)
self.unlocked = ttk.Label(self.balFrame,text =initBal[1],style = "unlocked.TLabel",)
self.balLabel.grid(row=1,column=0,sticky=tk.W,padx =(5,0),pady=(5,2))
self.balance.grid(row=2,column=0,sticky=tk.W,padx =(5,0),pady=(0,2))
self.unlockedLabel.grid(row=3,column=0,sticky=tk.W,padx =(5,0),pady=(0,2))
self.unlocked.grid(row=4,column=0,sticky=tk.W,padx =(5,0),pady=(0,5))
#self.go_send = tk.Button(self.extra,text = "send",command =self.get,image = self.moon3,compound = tk.CENTER,height = 18,width = 60,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 3,bg = "#900100" )
if not self.app.cold:
self.go_send = tk.Button(self,text = "send",command = self.go_send_event,height = 25,width = 60,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 5,bg = "red",image = self.bgv,compound = tk.CENTER,cursor = "exchange")
else:
self.go_coldsign = tk.Button(self,text = "cold sig",command = self.go_coldsign_event,height = 25,width = 60,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 5,bg = "skyblue1",image = self.bgv,compound = tk.CENTER,cursor = "exchange")
self.go_receive = tk.Button(self,text = "receive",command = self.go_receive_event,height = 25,width = 60,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 5,bg = "green",image = self.bg2,compound = tk.CENTER,cursor = "plus")
self.go_extras = tk.Button(self,text = "extras",command = self.go_extras_event,height = 25,width = 60,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 5,bg = "blue",image = self.bg3,compound = tk.CENTER,cursor = "trek",)
self.go_donate = tk.Button(self,text = "donate",command = self.go_donate_event,height = 25,width = 60,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 5,bg = "orange",image = self.bgv,compound = tk.CENTER,cursor = "heart")
self.showLogo.grid(row=0,column=0,sticky=tk.W)
self.account_picker.grid(row=0,column=0,padx =(5,0),pady=(5,5),sticky=tk.W+tk.E)
self.balFrame.grid(row=2,column=0,sticky=tk.W+tk.E)
if not self.app.cold:
self.go_send.grid(row=3,column=0,sticky=tk.W+tk.E,pady=(4,0),padx=(4,4))
else:
self.go_coldsign.grid(row=3,column=0,sticky=tk.W+tk.E,pady=(4,0),padx=(4,4))
self.go_receive.grid(row=4,column=0,sticky=tk.W+tk.E,pady=(4,0),padx=(4,4))
self.go_extras.grid(row=5,column=0,sticky=tk.W+tk.E,pady=(4,0),padx=(4,4))
self.go_donate.grid(row=6,column=0,sticky=tk.W+tk.E,pady=(4,0),padx=(4,4))
def go_send_event(self):
self.app.sendpage.lift()
def go_coldsign_event(self):
self.app.coldsignpage.lift()
def go_receive_event(self):
self.app.receivepage.lift()
def go_extras_event(self):
MessageBox.showinfo("Coming Soon","Extra Features under development, see github / Monero FFS")
def go_donate_event(self):
self.app.donatepage.lift()
def account_chosen(self):
try:
choice = self.account_picker.value.get()
index = self.app.account_dict[choice]["index"]
info,bals = self.app.wallet.account_switch(index = index)
self.balance.configure(text = bals[0])
self.unlocked.configure(text = bals[1])
info = "Currently selected account:\n" + info.split("Currently selected account: ")[-1]
info = info.replace("Balance: ","Balance:\n").replace(" unlocked balance: ","\nUnlocked:\n")
self.app.showinfo(info)
except Exception as e:
MessageBox.showerror("Account Switch Error",str(e) + "\nUnknown account state. Proceed with caution.")
finally:
self.app.receivepage.refresh()
def refresh_account(self,boot = False,current = None):
if boot:
self.app.account_help = self.app.wallet.account_helper(self.app.wallet.boot)
else:
result = self.app.wallet.account()
self.app.account_help = (result[1],result[2])
#print("account help",(self.app.account_help))
self.app.account_dict = self.app.account_help[0]
#print("account dict",(self.app.account_dict))
for menu in list(self.app.account_dict.keys()):
#print("account menu",(menu))
#print("account index",self.app.account_dict[menu]["index"])
if int(self.app.account_dict[menu]["index"]) == 0:
self.app.primary_account = menu
self.app.account_menu = self.app.account_help[1]
self.account_picker.value["values"] = list(self.app.account_menu)
if not current:
self.account_picker.value.set(self.app.primary_account)
def refresh(self):
if not self.parent.wallet.busy and not self.app.busy:
now = self.parent.wallet.balance(grandTotal = False)
self.balance.configure(text = now[0])
self.unlocked.configure(text = now[1])
self._root().after(self.delay,self.idle_refresh)
else:
self._root().after(5000,self.idle_refresh)
def idle_refresh(self,something = None):
self.app.after_idle(self.refresh)
class Statusbar(ttk.Frame):
def __init__(self,app, parent,delay = 70000,background = "misc/genericspace.gif", *args, **kwargs):
ttk.Frame.__init__(self, parent,style = "app.TFrame", *args, **kwargs)
self.app = app
self.parent = parent
if background and not self.app.light:
self.bg = tk.PhotoImage(file = background)
self.bglabel = tk.Label(self, image=self.bg)
self.bglabel.place(x=0, y=0, relwidth=1, relheight=1)
self.delay = delay
self.status = ttk.Label(self,text = "Checking Status...",style = "smaller.TLabel")
self.copyright = tk.Label(self, text = "(c) 2018 u/NASA_Welder",foreground="white", background="black",font=('Liberation Mono','10','normal'))
self.status.grid(row = 0, column =0,pady=(5,5))
self.copyright.grid(row = 0, column =1,sticky = tk.E,padx=(80,0))
def refresh(self,subRefresh = True):
if not self.parent.wallet.busy:
now = self.parent.wallet.status(refresh=subRefresh)
self.status.configure(text = now)
self._root().after(self.delay,self.idle_refresh)
else:
self._root().after(5000,self.idle_refresh)
def idle_refresh(self,subRefresh = True):
self._root().after_idle(self.refresh,subRefresh)
class PaneSelect(ttk.Frame):
def __init__(self,app, parent, *args, **kwargs):
ttk.Frame.__init__(self, parent,style = "app.TFrame", *args, **kwargs)
self.app = app
self.parent = parent
class Pane(ttk.Frame):
def __init__(self,app, parent,background = None,name = None, *args, **kwargs):
ttk.Frame.__init__(self, parent,style = "app.TFrame", *args, **kwargs)
self.app = app
self.parent = parent
if background and not self.app.light:
self.bg = tk.PhotoImage(file = background)
self.bglabel = tk.Label(self, image=self.bg)
self.bglabel.place(x=0, y=0, relwidth=1, relheight=1)
class Destination(ttk.Frame):
def __init__(self,app, parent,background = "misc/genericspace3.gif",cwidth = None,select_handle = "Address Book",mode = "send",name = "", *args, **kwargs):
ttk.Frame.__init__(self, parent,style = "app.TFrame", *args, **kwargs)
self.app = app
self.parent = parent
self.name = name
self.localmenu = None
self.mode = mode
if self.mode =="send":
if not self.app.address_book_menu:
self.app.address_book = self.app.wallet.address_book()
self.app.address_book_menu = [""]
for k,v in self.app.address_book.items():
self.app.address_book_menu.append(v["menu"])
self.app.address_book_menu.sort()
self.localmenu = self.app.address_book_menu
self.start = ""
self.cmd = self.address_book_chosen
elif self.mode == "receive":
if not self.app.subaddress_book_menu:
self.app.subaddress_book = self.app.wallet.address(address_all = True)
self.app.subaddress_book_menu = []
largest = 0
for k,v in self.app.subaddress_book.items():
largest = max(largest,int(k))
#self.app.subaddress_book_menu.append(v["menu"])
for i in range(largest+1):
self.app.subaddress_book_menu.append(self.app.subaddress_book[str(i)]["menu"])
self.localmenu = self.app.subaddress_book_menu
self.start = self.app.subaddress_book_menu[0]
#print("--------------------------STARTING SUB ADDRESS",self.start)
self.cmd = self.subaddress_book_chosen
if self.mode =="donate":
self.localmenu = [""]
self.start = ""
self.cmd = self.do_nothing
if background and not self.app.light:
self.bg = tk.PhotoImage(file = background)
self.bglabel = tk.Label(self, image=self.bg)
self.bglabel.place(x=0, y=0, relwidth=1, relheight=1)
self.heading = ttk.Label(self,text = "Address",style = "app.TLabel")
self.dest_address = tk.Text(self,bg = "white",height = 2,width = int(self.app.address_length/2)+1,insertbackground ="#D15101",selectbackground = "#D15101" )
self.amount = MyWidget(self.app,self,handle = self.name + "Amount",choices = "entry",)
self.address_book_select = MyWidget(self.app, self,handle = select_handle,cwidth = cwidth,choices=self.localmenu,startVal = self.start,cmd = self.cmd)
self.heading.grid(row=0,column=1,sticky = tk.W,pady= (0,0))
self.dest_address.grid(row=1,column=1,sticky = tk.E,pady= (0,0))
self.amount.grid(row=0,column=0,rowspan = 2,sticky = tk.NE,pady= (0,0),padx = (0,25))
if not self.mode =="donate":
self.address_book_select.grid(row=3,column=0,columnspan = 4,sticky = tk.E,pady= (5,0))
else:
self.nasawelder_address = "48Zuamrb7P5NiBHrSN4ua3JXRZyPt6XTzWLawzK9QKjTVfsc2bUr1UmYJ44sisanuCJzjBAccozckVuTLnHG24ce42Qyak6" # u/NASA_Welder
self.dest_insert(self.nasawelder_address)
self.dest_address.configure(state='disabled')
#for windows
self.address_book_select.bind("<MouseWheel>", self.empty_scroll_command)
# Linux and other *nix systems
self.address_book_select.bind("<ButtonPress-4>", self.empty_scroll_command)
self.address_book_select.bind("<ButtonPress-5>", self.empty_scroll_command)
if self.mode == "receive":
self._root().after(100,self.subaddress_book_chosen)
def empty_scroll_command(self, event):
return "break"
def do_nothing(self):
pass
def dest_insert(self,address):
self.dest_address.delete('1.0', tk.END)
self.dest_address.insert('1.0',address)
def address_book_chosen(self):
pick = self.address_book_select.get()[0]
if pick:
new_address = self.app.address_book[pick.split(":")[0]]["address"]
self.dest_insert(new_address)
else:
self.dest_insert("")
def subaddress_book_chosen(self):
pick = self.address_book_select.get()[0]
if pick:
new_address = self.app.subaddress_book[pick.split(":")[0]]["address"]
self.dest_address.configure(state='normal')
self.dest_insert(new_address)
self.dest_address.configure(state='disabled')
self._root().after(10,self.app.receivepage.genQR)
def get(self):
dest = self.dest_address.get("1.0",tk.END).strip()
amount = self.amount.get()[0]
try:
if len(dest) == self.app.address_length:
if float(amount) and float(amount) > 0.000000:
return dest + " " + amount
except ValueError as e:
err = "ERROR in tx #%s"%self.name.split(":")[0] + str(e)
raise Exception(err)
return None
class Coldsign(ttk.Frame):
def __init__(self,app, parent,background = "misc/genericspace2.gif", *args, **kwargs):
ttk.Frame.__init__(self, parent,style = "app.TFrame", *args, **kwargs)
self.app = app
self.parent = parent
if False:# self.app.light:
self.moon3 = tk.PhotoImage(file = "misc/moonbutton3.gif")
self.cold_transfer_button = tk.Button(self,text = "Sign tx",command =self.do_cold_sign,image = self.moon3,compound = tk.CENTER,height = 18,width = 60,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 3,bg = "#900100" )
self.cold_transfer_button.grid(row=0,column=0,sticky = tk.E,padx = (10,10),pady=(10,10))
else:
if background and not self.app.light:
self.bg = tk.PhotoImage(file = background)
self.bglabel = tk.Label(self, image=self.bg)
self.bglabel.place(x=0, y=0, relwidth=1, relheight=1)
self.heading = ttk.Label(self,text = "Cold Sign",style = "heading.TLabel")
self.moon3 = tk.PhotoImage(file = "misc/moonbutton3.gif")
#self.body = VSFrame(self,fheight = 430) # not yet
self.cold_transfer_button = tk.Button(self,text = "Sign tx",command =self.do_cold_sign,image = self.moon3,compound = tk.CENTER,height = 18,width = 60,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 3,bg = "#900100" )
self.heading.grid(row=0,column=0,sticky = tk.W,pady= (10,15))
#self.body.grid(row=1,column=0,sticky = tk.W+ tk.E,pady= (5,20))
self.cold_transfer_button.grid(row=1,column=1,sticky = tk.E,padx = (50,10),pady=(25,0))
def do_cold_sign(self):
self.app.cancel = False
self.app.outputs_payload = Payload("exoutp",app=self.app,signal_app = True)
self.app.scanner.add_child(self.app.outputs_payload)
self.app.preview_request()
self._root().after(10,self.app.monitor_incoming,self.app.outputs_payload,self.recv_qr_outputs)
def recv_qr_outputs(self,payload):
if not self.app.cancel:
try:
t = time.gmtime()
outputs_path = "imported_outputs_%s%s%s%s%s.lunlumo"% (t[0],t[7],t[3],t[4],t[5])
except:
outputs_path = "imported_outputs.lunlumo"
if payload.toFile(outputs_path):
self.app.wallet.import_outputs(outputs_path)
self._root().after(10,self.do_export_key_images)
else:
print(repr(payload.bin))
self.app.showerror("Stopped Automation","Failed crc.\nFailed to reconstruct QR stream: Outputs")
else:
self.app.showerror("Stopped Automation","Importing Outputs cancelled upstream.")
def do_export_key_images(self,):
if not self.app.cancel:
try:
t = time.gmtime()
key_images_path = "exported_key_images_%s%s%s%s%s.lunlumo"% (t[0],t[7],t[3],t[4],t[5])
except:
key_images_path = "exported_key_images.lunlumo"
self.app.wallet.export_key_images(key_images_path)
if not self.app.cancel:
self.app.sender = SendTop(self.app,self._root(),payloadType="keyimgs",payloadPath = key_images_path)
self.app.unsigned_tx_payload = Payload("unsgtx",app=self.app,signal_app = True)
self.app.scanner.add_child(self.app.unsigned_tx_payload)
self._root().after(10,self.app.monitor_incoming,self.app.unsigned_tx_payload,self.recv_qr_unsigned_tx)
else:
self.app.showerror("Stopped Automation","Exporting key images cancelled upstream.")
else:
self.app.showerror("Stopped Automation","Exporting key images cancelled upstream.")
def recv_qr_unsigned_tx(self,payload):
if not self.app.cancel:
unsigned_tx_path = "unsigned_%s_tx" % "monero" #self.app.coin # TODO u/stoffu when aeon change file name?
if payload.toFile(unsigned_tx_path):
self.app.wallet.sign_transfer()
if not self.app.cancel:
signed_tx_path = "signed_%s_tx" % "monero" #self.app.coin # TODO u/stoffu when aeon change file name?
self.app.sender = SendTop(self.app,self._root(),payloadType="sigdtx",payloadPath = signed_tx_path)
# TODO u/jollymort : should we re-sync outputs/keyimages here?
else:
self.app.showerror("Stopped Automation","sign_transfer cancelled upstream.")
else:
print(repr(payload.bin))
self.app.showerror("Stopped Automation","Failed crc.\nFailed to reconstruct QR stream: unsigned_tx")
else:
self.app.showerror("Stopped Automation","sign_transfer cancelled upstream.")
self.app.preview_cancel()
class Receive(ttk.Frame):
def __init__(self,app, parent,coin="monero",background = None, *args, **kwargs):
ttk.Frame.__init__(self, parent,style = "app.TFrame", *args, **kwargs)
self.app = app
self.parent = parent
self.coin = self.app.coin
if background and not self.app.light:
self.bg = tk.PhotoImage(file = background)
self.bglabel = tk.Label(self, image=self.bg)
self.bglabel.place(x=0, y=0, relwidth=1, relheight=1)
self.heading = ttk.Label(self,text = "Receive",style = "heading.TLabel")
#self.body = VSFrame(self,fheight = 430,nobar = True)
self.dest = Destination(self.app,self,name = "",cwidth = 40,select_handle = "Subaddress Book",background = "misc/genericspace.gif",mode = "receive")
self.addresses = []
#self.textAddress = MyWidget(self.app,self.body.interior,handle = "Address",choices = [self.app.initAddress],cwidth = 50,startVal = self.app.initAddress )
self.amountVar = tk.StringVar()
self.dest.amount.value.config(textvariable = self.amountVar)
self.new_label = MyWidget(self.app,self,handle = "New Subaddress",ewidth=23,choices = "entry",startVal = "<label goes here>")
self.moon3 = tk.PhotoImage(file = "misc/moonbutton3.gif")
if "monero" not in sys.argv[1]:
self.new_button = tk.Button(self,text = "New Sub.",command =self.new_subaddress,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 3,bg = "#2D89A0" )
else:
self.new_button = tk.Button(self,text = "New Sub.",command =self.new_subaddress,image = self.moon3,compound = tk.CENTER,height = 18,width = 60,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 3,bg = "#900100" )
#self.amount = MyWidget(self.app,self.body.interior,handle = "Amount",choices = "entry",optional = True,activeStart=False)
#self.amount.value.configure(textvariable = self.amountVar)
self.amountVar.trace("w", lambda name, index, mode, sv=self.amountVar: self.amountCallback(sv))
#self.amount.optState.trace("w", lambda name, index, mode, sv=self.amountVar: self.amountCallback(sv))
self.qr = ttk.Label(self,style = "app.TLabel")
self.genQR()
self.heading.grid(row=0,column=0,sticky = tk.W,pady= (10,15))
#self.body.grid(row=1,column=0,sticky = tk.W+ tk.E,pady= (5,20))
self.dest.grid(row=1,column=0,columnspan = 2,sticky = tk.W,padx = (15,15))
self.new_label.grid(row=2,column=0,sticky = tk.W,padx = (109,0),pady=(15,0))
self.new_button.grid(row=2,column=1,sticky = tk.W,padx = (0,10),pady=(25,0))
#self.textAddress.grid(row=1,column=0,columnspan = 2,sticky = tk.W)
#self.amount.grid(row=2,column=1,sticky = tk.E,pady= (10,0))
self.qr.grid(row=3,column=0,sticky = tk.W+tk.E,padx=(140,0),pady= (15,80),columnspan = 3)
def new_subaddress(self):
label = self.new_label.get()[0]
self.app.wallet.address_new(label = label)
self.refresh(index = -1)
def idle_refresh(self,something = None):
self._root().after_idle(self.refresh)
def refresh(self,index = 0):
#self.grid_propagate(False)
###
self.app.subaddress_book = self.app.wallet.address(address_all = True)
self.app.subaddress_book_menu = []
largest = 0
for k,v in self.app.subaddress_book.items():
largest = max(largest,int(k))
#self.app.subaddress_book_menu.append(v["menu"])
for i in range(largest+1):
self.app.subaddress_book_menu.append(self.app.subaddress_book[str(i)]["menu"])
###
zero = self.app.subaddress_book_menu[index]
self.dest.address_book_select.value["values"] = list(self.app.subaddress_book_menu)
self.dest.address_book_select.value.set(zero)
self.dest.subaddress_book_chosen()
self.genQR()
def getAddresses(self):
addlist = self.app.wallet.address()
return addlist
def amountCallback(self,event = None,arg = None):
#self.grid_propagate(False)
self._root().after(200,self.genQR)
def genQR(self):
msg = self.app.coin + ":" + self.dest.dest_address.get("1.0",tk.END).strip()
if self.dest.amount.get()[0]:
try:
valid = float(self.dest.amount.get()[0])
msg += "?tx_amount=" + self.dest.amount.get()[0]
except ValueError as e:
self.dest.amount.value.delete(0, tk.END)
MessageBox.showerror("Amount Error",str(e))
self.qrPage = pyqrcode.create(msg,error="L")
self.code = tk.BitmapImage(data=self.qrPage.xbm(scale=5))
self.code.config(background="gray70")
self.qr.config(image = self.code)
class SendPane(ttk.Frame):
def __init__(self,app, parent,background = None,delay = 35000, *args, **kwargs):
ttk.Frame.__init__(self, parent,style = "app.TFrame", *args, **kwargs)
self.app = app
self.parent = parent
self.delay = delay
if background and not self.app.light:
self.bg = tk.PhotoImage(file = background)
self.bglabel = tk.Label(self, image=self.bg)
self.bglabel.place(x=0, y=0, relwidth=1, relheight=1)
self.build_page(background)
def build_page(self,background):
self.heading = ttk.Label(self,text = "Send",style = "heading.TLabel")
self.destFrame = VSFrame(self,fheight = 275)
self.dests = []
for i in range(10):
if i in [1,4,7,]:
b = "misc/genericspace3.gif"
elif i in [2,5,8,]:
b = "misc/genericspace.gif"
else:
b = "misc/genericspace2.gif"
dest = Destination(self.app,self.destFrame.interior,name = "%s: "% str(i+1),background = b)
dest.pack(padx=(0,20),pady=(0,15))
self.dests.append(dest)
#############################
self.extra = ttk.Frame(self,style = "app.TFrame",)
self.moon3 = tk.PhotoImage(file = "misc/moonbutton3.gif")
if background and not self.app.light:
self.bge = tk.PhotoImage(file = background)
self.bglabele = tk.Label(self.extra, image=self.bge)
self.bglabele.place(x=0, y=0, relwidth=1, relheight=1)
self.payid_title = ttk.Label(self.extra,text = "Payment ID (optional)",style = "app.TLabel")
self.payment_id_entry = tk.Text(self.extra,bg = "white",height = 2,width = 33,insertbackground ="#D15101",selectbackground = "#D15101" )
self.priority = MyWidget(self.app,self.extra,handle = "Priority",choices = ["unimportant","normal","elevated","priority"],startVal = "unimportant")
self.privacy = MyWidget(self.app,self.extra,handle = "Privacy",choices = [str(i) for i in range(5,51)],startVal = 5)
if "monero" not in sys.argv[1]:
self.send_button = tk.Button(self.extra,text = "send",command =self.get,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 3,bg = "#2D89A0" )
else:
self.send_button = tk.Button(self.extra,text = "send",command =self.get,image = self.moon3,compound = tk.CENTER,height = 18,width = 60,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 3,bg = "#900100" )
self.payid_title.grid(row=0,column=1,columnspan=2,sticky = tk.W,)
self.payment_id_entry.grid(row=1,column=1,columnspan=2,sticky = tk.E)
self.priority.grid(row=2,column=1,sticky = tk.E,pady=(10,0))
self.privacy.grid(row=2,column=2,sticky = tk.E,pady=(10,0))
self.send_button.grid(row=3,column=2,sticky = tk.E,pady=(15,0))
self.fee_frame = ttk.Frame(self.extra,style = "app.TFrame",width = 200)
if background and not self.app.light:
self.bgf = tk.PhotoImage(file = background)
self.bglabelf = tk.Label(self.fee_frame, image=self.bgf)
self.bglabelf.place(x=0, y=0, relwidth=1, relheight=1)
self.fee_title = ttk.Label(self.fee_frame,text = "Backlog / Network Fees",style = "app.TLabel")
self.cost = ttk.Label(self.fee_frame,text = "<waiting for network fees>",style = "smaller.TLabel")
self.backlog1 = ttk.Label(self.fee_frame,text = "<waiting for unimportant backlog>",style = "smaller.TLabel")
self.backlog2 = ttk.Label(self.fee_frame,text = "<waiting for normal backlog>",style = "smaller.TLabel")
self.backlog3 = ttk.Label(self.fee_frame,text = "<waiting for elevated backlog>",style = "smaller.TLabel")
self.backlog4 = ttk.Label(self.fee_frame,text = "<waiting for priority backlog>",style = "smaller.TLabel")
self.fee_title.grid(row=0,column=0,columnspan=1,sticky = tk.W,)
self.cost.grid(row=1,column=0,columnspan=1,sticky = tk.W,)
self.backlog1.grid(row=2,column=0,columnspan=1,sticky = tk.W,)
self.backlog2.grid(row=3,column=0,columnspan=1,sticky = tk.W,)
self.backlog3.grid(row=4,column=0,columnspan=1,sticky = tk.W,)
self.backlog4.grid(row=5,column=0,columnspan=1,sticky = tk.W,)
self.fee_frame.grid(row=0,column=0,columnspan=1,rowspan = 5,sticky = tk.NW,padx=(0,15))
#############################
self.heading.grid(row=0,column=0,sticky = tk.W,pady= (10,20))
self.destFrame.grid(row=1,column=0,columnspan = 3,pady = (0,25),)
self.extra.grid(row=2,column=0,columnspan = 3,sticky = tk.E,pady=(10,0),padx=(0,15))
def get(self):
self.app.cancel = False
self.app.current_transfer_cmd = ""
# transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <amount> [<payment_id>]
tx_string = "transfer %s %s" % (self.priority.get()[0],self.privacy.get()[0])
dest_substring = ""
try:
for dest in self.dests:
result = dest.get()
if result:
dest_substring += " " + result
except Exception as e:
MessageBox.showerror("Transaction Error",str(e) )
return
if not dest_substring:
MessageBox.showerror("Transaction Error","No valid destination + amounts found" )
return
tx_string += dest_substring
pay_id = self.payment_id_entry.get("1.0",tk.END).strip()
if pay_id:
if not len(pay_id) == 64 or not pay_id.isalnum():
MessageBox.showerror("Transaction Error","Invalid Payment ID\n\n%s\n\nMust be 64 chars and alphanumeric" % pay_id)
return
tx_string += " " + pay_id
#print("Transfer cmd:\n",repr(tx_string))
if not "Opened watch-only wallet:" in self.app.wallet.boot or not self.app.scanner:
info = self.app.wallet.transfer(tx_string)
if not "Transaction successfully submitted" in info:
self.app.showinfo(info)
else:
self.app.current_transfer_cmd = tx_string
try:
t = time.gmtime()
outputs_file = "exported_outputs_%s%s%s%s%s.lunlumo"% (t[0],t[7],t[3],t[4],t[5])
except:
outputs_file = "exported_outputs.lunlumo"
self.app.wallet.export_outputs(outputsFileName = outputs_file)
self.app.sender = SendTop(self.app,self._root(),payloadType="exoutp",payloadPath = outputs_file,)
self.app.key_images_payload = Payload("keyimgs",app=self.app,signal_app = True)
self.app.scanner.add_child(self.app.key_images_payload)
self.app.preview_request()
self._root().after(10,self.app.monitor_incoming,self.app.key_images_payload,self.recv_qr_key_images)
def recv_qr_key_images(self,payload):
if not self.app.cancel:
try:
t = time.gmtime()
key_images_path = "imported_key_images_%s%s%s%s%s.lunlumo"% (t[0],t[7],t[3],t[4],t[5])
except:
key_images_path = "imported_key_images.lunlumo"
if payload.toFile(key_images_path):
self.app.wallet.import_key_images(key_images_path)
self._root().after(10,self.make_unsigned_tx)
else:
self.app.showerror("Stopped Automation","Failed crc.\nFailed to reconstruct QR stream: Key Images")
else:
self.app.showerror("Stopped Automation","Importing key images cancelled upstream.")
def make_unsigned_tx(self,):
if not self.app.cancel:
self.app.wallet.transfer(self.app.current_transfer_cmd)
self.app.current_transfer_cmd = ""
if not self.app.cancel:
self.app.sender = SendTop(self.app,self._root(),payloadType="unsgtx",payloadPath = "unsigned_monero_tx",) # TODO when will aeon change file name? u/stoffu
self.app.signed_tx_payload = Payload("sigdtx",app=self.app,signal_app = True)
self.app.scanner.add_child(self.app.signed_tx_payload)
self._root().after(10,self.app.monitor_incoming,self.app.signed_tx_payload,self.recv_qr_signed_tx)
else:
self.app.showerror("Stopped Automation","Sending unsigned_tx cancelled upstream.")
else:
self.app.showerror("Stopped Automation","Making unsigned_tx cancelled upstream.")
def recv_qr_signed_tx(self,payload):
if not self.app.cancel:
signed_tx_path = "signed_%s_tx" % "monero" #self.app.coin # TODO u/stoffu when aeon change file name?
if payload.toFile(signed_tx_path):
self.app.wallet.submit_transfer()
#self._root().after(10,self.make_unsigned_tx)
else:
self.app.showerror("Stopped Automation","Failed crc.\nFailed to reconstruct QR stream: signed_tx")
else:
self.app.showerror("Stopped Automation","Submitting transfer cancelled upstream.")
self.app.preview_cancel()
def idle_refresh(self,something = None):
self._root().after_idle(self.refresh)
def refresh(self):
self.fee_frame.grid_propagate(False)
if not self.parent.wallet.busy:
fee_info = self.app.wallet.fee()
self.cost.config(text=fee_info[0].replace("Current fee is ",""))
self.backlog1.config(text=fee_info[1].replace("priority 1","unimportant"))
self.backlog2.config(text=fee_info[2].replace("priority 2","normal"))
self.backlog3.config(text=fee_info[3].replace("priority 3","elevated"))
self.backlog4.config(text=fee_info[4].replace("priority 4","priority"))
self._root().after(self.delay,self.idle_refresh)
##########################
class Donate(SendPane):
def __init__(self,app, parent,background = "misc/genericspace3.gif", *args, **kwargs):
SendPane.__init__(self,app, parent,background = "misc/genericspace3.gif", *args, **kwargs)
self.app = app
self.parent = parent
if background and not self.app.light:
self.bg = tk.PhotoImage(file = background)
self.bglabel = tk.Label(self, image=self.bg)
self.bglabel.place(x=0, y=0, relwidth=1, relheight=1)
self.build_page(background)
def build_page(self,background):
self.heading = ttk.Label(self,text = "Donate",style = "heading.TLabel")
#self.destFrame = VSFrame(self,fheight = 230)
self.mydest = Destination(self.app,self,name = "" ,background = "misc/genericspace.gif",mode = "donate")
self.dests = [self.mydest]
self.blurb = ttk.Label(self,text = "Thanks for using lunlumo. Continued development is made possible by letting my rugrat play with the kids at daycare. Consider chipping in to the babysitting fund.",style = "app.TLabel",wraplength = 485)
self.author = ttk.Label(self,text = "- u/NASA_Welder",style = "app.TLabel")
#############################
self.extra = ttk.Frame(self,style = "app.TFrame",)
self.moon3 = tk.PhotoImage(file = "misc/moonbutton3.gif")
#self.payid_title = ttk.Label(self.extra,text = "Payment ID (optional)",style = "app.TLabel")
self.payment_id_entry = tk.Text(self,bg = "white",height = 2,width = 33,insertbackground ="#D15101",selectbackground = "#D15101" )
self.priority = MyWidget(self.app,self,handle = "Priority",choices = ["unimportant","normal","elevated","priority"],startVal = "unimportant")
self.privacy = MyWidget(self.app,self,handle = "Privacy",choices = [str(i) for i in range(5,51)],startVal = 5)
if "monero" not in sys.argv[1]:
self.send_button = tk.Button(self,text = "send",command =self.get,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 3,bg = "#2D89A0" )
else:
self.send_button = tk.Button(self,text = "send",command =self.get,image = self.moon3,compound = tk.CENTER,height = 18,width = 60,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 3,bg = "#900100" )
self.amountVar = tk.StringVar()
self.mydest.amount.value.config(textvariable = self.amountVar)
self.amountVar.trace("w", lambda name, index, mode, sv=self.amountVar: self.amountCallback(sv))
self.qr = ttk.Label(self,style = "app.TLabel")
self.genQR()
#self.payid_title.grid(row=0,column=1,columnspan=2,sticky = tk.W,)
#self.payment_id_entry.grid(row=1,column=1,columnspan=2,sticky = tk.E)
#self.priority.grid(row=2,column=1,sticky = tk.E,pady=(10,0))
#self.privacy.grid(row=2,column=2,sticky = tk.E,pady=(10,0))
#############################
self.heading.grid(row=0,column=0,columnspan = 3,sticky = tk.W,pady= (10,15))
self.mydest.grid(row=3,column=0,columnspan = 3,sticky = tk.NW + tk.E,padx = (30,0),pady = (15,0),)
self.send_button.grid(row=4,column=2,sticky = tk.N,pady=(20,0),rowspan = 2)
self.qr.grid(row=5,column=0,sticky = tk.W+tk.E,padx=(10,0),pady= (35,30),columnspan = 2)
self.blurb.grid(row=1,column=0,sticky = tk.W+tk.E,padx=(5,0),pady= (5,0),columnspan = 3)
self.author.grid(row=2,column=0,sticky = tk.W+tk.E,padx=(235,0),pady= (0,0),columnspan = 3)
#self.destFrame.grid(row=1,column=0,columnspan = 3,pady = (0,25),)
#self.extra.grid(row=2,column=0,columnspan = 3,sticky = tk.E,pady=(10,0),padx=(0,15))
def amountCallback(self,event = None,arg = None):
self.grid_propagate(False)
self._root().after(200,self.genQR)
def genQR(self):
msg = "monero" + ":" + self.mydest.dest_address.get("1.0",tk.END).strip()
if self.mydest.amount.get()[0]:
try:
msg += "?tx_amount=" + str(float(self.mydest.amount.get()[0]))
except ValueError as e:
self.mydest.amount.value.delete(0, tk.END)
MessageBox.showerror("Amount Error",str(e))
self.qrPage = pyqrcode.create(msg,error="L")
self.code = tk.BitmapImage(data=self.qrPage.xbm(scale=5))
self.code.config(background="gray75")
self.qr.config(image = self.code)
##########################
class FilePicker(ttk.Frame):
def __init__(self,app, parent,handle,start = None,buttonName = "Select",askPass = False,background = None,ftypes = [("all","*")],idir="./", *args, **kwargs):
tk.Frame.__init__(self, parent,highlightcolor = "white",highlightbackground = "white",highlightthickness=3,background ="#4C4C4C" , *args, **kwargs)
self.app = app
self.parent = parent
self.handle = handle
self.ftypes = ftypes
self.idir = idir
self.askPass = askPass
self.moon1 = tk.PhotoImage(file = "misc/moonbutton1.gif")
self.moon2 = tk.PhotoImage(file = "misc/moonbutton2.gif")
self.moon3 = tk.PhotoImage(file = "misc/moonbutton3.gif")
if background:
self.bg = tk.PhotoImage(file = background)
self.bglabel = tk.Label(self, image=self.bg)
self.bglabel.place(x=0, y=0, relwidth=1, relheight=1)
self.title = ttk.Label(self,text = self.handle,style = "app.TLabel")
self.displayVar = tk.StringVar()
self.displayVar.set("*")
self.selectVar = tk.StringVar()
self.selectVar.set("")
self.passlbl = ttk.Label(self,text = "password:",style = "app.TLabel")
self.password = tk.Entry(self,text = self.handle,insertofftime=5000,show = "*",width = 13,foreground = "white")
if start:
self.selectVar.set(start)
self.displayVar.set(os.path.basename(start))
self.select = ttk.Label(self,textvariable = self.displayVar,wraplength=210,style = "app.TLabel")
#self.button = ttk.Button(self,text = buttonName,style = "app.TButton",command =self.dialog )
if "monero" not in sys.argv[1]:
self.button = tk.Button(self,text = "select",command =self.dialog,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 3,bg = "#2D89A0" )
else:
self.button = tk.Button(self,text = "select",command =self.dialog,image = self.moon2,compound = tk.CENTER,height = 18,width = 60,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 3,bg = "#900100" )
self.title.grid(row = 0,column = 0,padx=(5,0))
self.button.grid(row = 0,column = 1,padx=6,pady = 6)
self.select.grid(row = 1,column = 0,sticky = tk.W,columnspan = 3,padx=(5,0),pady=(0,3))
if self.askPass:
self.passlbl.grid(row = 2,column = 0,sticky = tk.W,padx=(5,3))
self.password.grid(row = 2,column = 1,sticky = tk.W,padx=(0,7),pady = (0,8))
def dialog(self):
choice = FileDialog.askopenfilename(filetypes=self.ftypes,initialdir = self.idir,title = self.handle)
self.password.delete(0,tk.END)
if choice:
self.displayVar.set(os.path.basename(choice))
self.selectVar.set(choice)
else:
self.displayVar.set("*")
self.selectVar.set("")
def get(self):
if not self.askPass:
if self.selectVar.get() == "":
return None
return self.selectVar.get()
else:
if self.selectVar.get() == "":
return None,None
return self.selectVar.get(),self.password.get()
class Login(ttk.Frame):
def __init__(self,app, parent,settings,background = None,*args, **kwargs):
ttk.Frame.__init__(self, parent,style = "app.TFrame", *args, **kwargs)
self.app = app
self.parent = parent
self.settings = settings
self.final = None
self.light = False
self.moon1 = tk.PhotoImage(file = "misc/moonbutton1.gif")
self.moon2 = tk.PhotoImage(file = "misc/moonbutton2.gif")
self.moon3 = tk.PhotoImage(file = "misc/moonbutton3.gif")
if background:
self.bg = tk.PhotoImage(file = background)
self.bglabel = tk.Label(self, image=self.bg)
self.bglabel.place(x=0, y=0, relwidth=1, relheight=1)
if "monero-wallet-cli" in os.path.basename(sys.argv[1]):
self.logo = tk.PhotoImage(file = "misc/reddit_user_philkode_made_this.gif")
else:
self.logo = tk.PhotoImage(file = "misc/aeon_logo2.gif")
self.showLogo = ttk.Label(self,image= self.logo,style = "app.TLabel",cursor = "shuttle")
#heading = ttk.Label(first,text= "Wallet Options",style = "app.TLabel")
self.walletFile = FilePicker(self.app,self,"wallet file",askPass = True,start = self.settings["wallet"]["wallet_file"],background = "misc/genericspace.gif",ftypes = [("full","*.keys"),("watchonly","*.keys-watchonly")],idir=os.path.dirname(sys.argv[1]))
self.testnet = MyWidget(self,self,handle = "testnet",optional = 1,activeStart=self.settings["wallet"]["testnet"])
if "monero" not in sys.argv[1]:
self.launch = tk.Button(self,text = "launch!",command =self.launch,cursor = "shuttle",highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 3,bg = "#2D89A0" )
else:
self.launch = tk.Button(self,text = "launch!",command =self.launch,cursor = "shuttle",image = self.moon3,compound = tk.CENTER,height = 18,width = 60,highlightthickness=0,font=('Liberation Mono','12','normal'),foreground = "white",bd = 3,bg = "#900100" )
#MyWidget(app, parent,handle,choices=None,subs = {},allowEntry = False,optional = False,activeStart=1,ewidth = 8,cwidth = None, cmd = None)
dstart = None
try:
if settings["wallet"]["testnet"]:
dstart = self.settings["wallet"]["host[:port]"]["testnet"]