예제 #1
0
	def __init__(self,parent_frame):
		self.grid_settings=[]
		self.update_in_progress=False

		idb=localdb.DB()
		
		frame0=ttk.LabelFrame(parent_frame,text='Filter') #
		frame0.grid(row=0,column=0, sticky="nsew")
		
		task_done=idb.select('queue_done', ['command'],distinct=True)
		tmpcommands=[cc[0] for cc in task_done]
		tmpdict={}
		tmpdict['filters']=[{'T':'LabelC', 'L':'Category: '}
							, {'T':'Combox', 'uid':'category', 'V':['All','manual','auto'] }
							, {'T':'LabelC', 'L':'Command: '}
							, {'T':'Combox', 'uid':'command', 'V':['All']+tmpcommands }
							, {'T':'LabelC', 'L':'Last: '}
							, {'T':'Combox', 'uid':'last', 'V':['24h','week','month','12 months','All'] }
							, {'T':'LabelC', 'L':'Result: '}
							, {'T':'Combox', 'uid':'result', 'V':['All','Failed','Success','Cancelled'] }
							]
						
		grid_filter=[]
		grid_filter.append(tmpdict )
		
		self.filter_table=flexitable.FlexiTable(frame0,grid_filter) 
		# addr book view left:
		frame1=ttk.LabelFrame(parent_frame,text='Tasks list') 
		frame1.grid(row=1,column=0, sticky="nsew")
			
		tmpdict={}
		tmpdict['head']=[{'T':'LabelC', 'L':'Category' } , 
						{'T':'LabelC', 'L':'Command' } , 
						{'T':'LabelC', 'L':'Command json' } , 
						{'T':'LabelC', 'L':'Created at' } , 
						{'T':'LabelC', 'L':'Finished at' } , 
						{'T':'LabelC', 'L':'Result' } , 
						{'T':'LabelC', 'L':'wait_seconds' } , 
						{'T':'LabelC', 'L':'Result details' }
						]		
						
		self.grid_settings.append(tmpdict)
		
		self.update_list()
		
		self.main_table=flexitable.FlexiTable(frame1,self.grid_settings, min_canvas_width=1200,force_scroll=True)
		
		self.filter_table.bind_combox_cmd('category',[], self.update_history_frame )	
		self.filter_table.bind_combox_cmd('result',[],  self.update_history_frame )	
		self.filter_table.bind_combox_cmd('command',[],  self.update_history_frame )	
		self.filter_table.bind_combox_cmd('last',[],  self.update_history_frame )
예제 #2
0
 def set_queue():
     global wds  #, queue_status
     grid_lol4 = wds.prepare_queue_frame(True)
     queue_status = flexitable.FlexiTable(queue, grid_lol4, 400,
                                          True)  #params=None, grid_lol=None
     wds.queue_frame_buttons(grid_lol4, queue_status)
     addit_frames['queue_status'] = queue_status
예제 #3
0
    def update_msg_frame(self, *evargs):

        while self.updating_chat:
            time.sleep(1)

        self.updating_chat = True

        try:
            self.proc_inout()
            self.update_list()

            if len(self.thr_ord) > 0:
                if self.cur_uid not in self.valid_uids:
                    self.cur_uid = self.valid_uids[0]
            # if hasattr(self,'cur_uid')==False:
            # if len(self.thr_ord )>0:
            # self.cur_uid=self.valid_uids[0]

            if hasattr(self, 'cur_uid'):

                if self.main_table == None:
                    self.main_table = flexitable.FlexiTable(
                        self.frame1,
                        self.grid_threads_msg[self.cur_uid],
                        min_canvas_width=700,
                        force_scroll=True)
                else:
                    self.main_table.update_frame(
                        self.grid_threads_msg[self.cur_uid], -1)

                self.set_edit_alias_action(self.cur_uid)
            self.updating_chat = False
        except:
            self.updating_chat = False
예제 #4
0
	def __init__(self,parent_frame,notebook_parent,addr_book  ):
	
		self.init=True
		
		self.update_in_progress=False
		self.notebook_parent=notebook_parent
		self.addr_book=addr_book
		
		frame0=ttk.LabelFrame(parent_frame,text='Filter')  
		frame0.grid(row=0,column=0, sticky="nsew")
		
		tmpdict={}
		tmpdict['filters']=[{'T':'LabelC', 'L':'Category: '}
							, {'T':'Combox', 'uid':'category', 'V':['New','Closed'] }
							, {'T':'Button', 'uid':'clearall', 'L':'Close all' }
							]
		grid_filter=[]
		grid_filter.append(tmpdict )
		
		self.filter_table=flexitable.FlexiTable(frame0,grid_filter) 
		
		self.filter_table.bind_combox_cmd('category',[], self.update_notif_frame )	
		self.filter_table.set_cmd('clearall',[], self.close_all_notif )	
		
		self.grid_notif=[]
		
		frame1=ttk.LabelFrame(parent_frame,text='Notifications list') 
		frame1.grid(row=1,column=0, sticky="nsew")
	
		tmpdict={}
		tmpdict['head']=[{'T':'LabelC', 'L':'Date time' } , 
						{'T':'LabelC', 'L':'Event' } , 
						{'T':'LabelC', 'L':'Operation details' } , 
						{'T':'LabelC', 'L':'Status' },
						{ } , # ok clear
						{ }  # try again
						]		
						
		self.grid_notif.append(tmpdict)

		self.update_list()
		
		self.main_table=flexitable.FlexiTable(frame1,self.grid_notif, min_canvas_width=1200,force_scroll=True)
		self.set_actions()
		self.notebook_parent.tab(1,text='Notif. ('+str(len(self.grid_notif)-1)+')' )
		self.init=False
예제 #5
0
    def get_addr_from_wallet(self,
                             send_from,
                             addram,
                             sending_to=False,
                             *evargs):
        # print('send_from',send_from)
        # print('addram',addram)
        selframe = Toplevel()  #tk.Tk()
        selframe.title('Select address ')
        filter_frame = ttk.LabelFrame(selframe, text='Filter')
        filter_frame.grid(row=0, column=0)

        filtbox = ttk.Combobox(filter_frame,
                               textvariable='All',
                               values=self.own_wallet_categories(),
                               state="readonly")
        filtbox.current(0)
        filtbox.pack()

        grid_lol_select = self.prepare_own_addr_frame('All',
                                                      sending_to)  # 4 sec

        list_frame = ttk.LabelFrame(selframe, text='Addresses list')
        list_frame.grid(row=1, column=0)
        select_table = flexitable.FlexiTable(list_frame, grid_lol_select, 800,
                                             True)  #params=None, grid_lol=None

        self.prepare_own_addr_button_cmd(grid_lol_select, select_table,
                                         send_from, addram)

        def refresh_add_list(*eventsargs):
            filterval = filtbox.get()

            grid_lol_select = self.prepare_own_addr_frame(
                filterval, sending_to)
            select_table.update_frame(grid_lol_select)

        filtbox.bind("<<ComboboxSelected>>", refresh_add_list)
예제 #6
0
		def review(strjson,from_name,rev_id,*evargs):
			# print('rev click')
			
			formframe = Toplevel() 
			formframe.title('Review payment request from '+from_name)
			todisp=app_fun.json_to_str(json.loads(strjson))
			
			grid1=[]
			grid1.append( {'request':[{'T':'LabelC', 'L':todisp, 'width':96}, {'T':'LabelE' } ]} )
			tmpfromaddr=localdb.get_last_addr_from( "'last_book_from_addr'")
			grid1.append( {'label':[   {'T':'LabelC', 'L':'Send from:' } , {'T':'LabelE' } ]} )
			grid1.append( {'selectaddr':[ {'T':'Button', 'L':tmpfromaddr,  'uid':'seladdr', 'width':96} , {'T':'LabelE' } ]} )
			grid1.append( {'decide':[{'T':'Button', 'L':'Approve and Send',  'uid':'approve', 'width':32},  {'T':'Button', 'L':'Reject',  'uid':'reject'} ]} )
			g1_table=flexitable.FlexiTable(formframe,grid1)	
			
			def close_request( decis,*evargs):
				# print('decis',decis)
				idb=localdb.DB()
				table={}
				table['notifications']=[ {'opname':'PaymentRequest '+decis,'closed':'True' }]
				# print(rev_id)
				try:
					id=int(rev_id )
					# print('id',id)
					idb.update(table,['opname','closed'],{'uid':['=',id]} )
				except:
					# print('bad id?? 141 notif')
					pass
					
				formframe.destroy()
				
			def approve(*evargs):
			
				tmpdict=json.loads(strjson)
				# print('approved ',tmpdict)
				
				tmpsignature=localdb.get_addr_to_hash(tmpdict['toaddress'])
				tmpfromaddr=g1_table.get_value('seladdr') #localdb.get_last_addr_from( "'last_book_from_addr'")
				memotxt='Payment for '+tmpdict['title']
				if len(tmpdict['docuri'].strip())>1:
					memotxt+=' docuri: '+tmpdict['docuri']
				memotxt+=tmpsignature

				ddict={'fromaddr':tmpfromaddr, 'to':[{'z':tmpdict['toaddress'],'a':tmpdict['amount'],'m':memotxt }]	} 
				table={}
				table['queue_waiting']=[localdb.set_que_waiting('send',jsonstr=json.dumps(ddict) ) ]
				idb=localdb.DB()
				idb.insert(table,['type','wait_seconds','created_time','command' ,'json','id','status' ])
				
				# 1. send tx
				# 2. update notifications closed and opname
				
				close_request('Approved')
				flexitable.showinfo('Payment Request approved','Payment Request to address of amount '+str(tmpdict['amount'])+'\n'+tmpdict['toaddress']+'\nAPPROVED')
		
		
		# task_done=idb.select('notifications', ['uid','datetime' ,'opname' ,'details' ,'status' ,'closed','orig_json'],where=wwhere,orderby=[{'uid':'desc'}])
			
			# def selecting_addr_from_book_set_and_destroy_sending(addr,uid,frame_to_destroy,*evargs ):				
				# uid.set(addr)
				# frame_to_destroy.destroy()	
			
			g1_table.set_cmd('approve',[ ], approve )
			# g1_table.set_cmd('seladdr',[ ], approve )
			g1_table.set_cmd('seladdr',[  g1_table, ['seladdr'] ], self.addr_book.get_addr_from_wallet )
			g1_table.set_cmd('reject',[ 'Rejected'  ], close_request )
예제 #7
0
        def request_payment(alias, addr, update_fun, sendto_fun):

            formframe = Toplevel()
            formframe.title('Request payment from ' + alias)
            obligatory = ttk.Frame(formframe)
            obligatory.grid(row=0, column=0, sticky='NW')
            grid1 = []
            grid1.append({
                'line1': [{
                    'T': 'LabelC',
                    'L': 'Obligatory:'
                }, {
                    'T': 'LabelE'
                }]
            })
            grid1.append({
                'amount': [{
                    'T': 'LabelC',
                    'L': 'Request amount'
                }, {
                    'T': 'InputFloat',
                    'L': '0',
                    'uid': 'amount',
                    'width': 32
                }]
            })
            select = localdb.get_last_addr_from("'last_payment_to_addr'")
            grid1.append({
                'toaddress': [{
                    'T': 'LabelC',
                    'L': 'Payment to address'
                }, {
                    'T': 'Button',
                    'L': select,
                    'uid': 'toaddr',
                    'width': 32
                }]
            })
            grid1.append({
                'line1': [{
                    'T': 'LabelC',
                    'L': 'Optional:'
                }, {
                    'T': 'LabelE'
                }]
            })
            grid1.append({
                'title': [{
                    'T': 'LabelC',
                    'L': 'Title'
                }, {
                    'T': 'InputL',
                    'L': 'Payment request for invoice nr ',
                    'uid': 'title',
                    'width': 32
                }]
            })
            grid1.append({
                'docuri': [{
                    'T': 'LabelC',
                    'L': 'Document URI'
                }, {
                    'T': 'InputL',
                    'uid': 'docuri',
                    'width': 32
                }]
            })
            select = localdb.get_last_addr_from("'last_book_from_addr'")
            grid1.append({
                'sendfrommyaddr': [{
                    'T': 'LabelC',
                    'L': 'Send using'
                }, {
                    'T': 'Button',
                    'L': select,
                    'uid': 'sendfromaddr',
                    'width': 32
                }]
            })
            grid1.append({
                'submit': [{
                    'T': 'Button',
                    'L': 'Send request',
                    'span': 2,
                    'uid': 'submit'
                }, {}]
            })

            g1_table = flexitable.FlexiTable(obligatory, grid1)

            # def selecting_addr_from_book_set_and_destroy_sending( addr,uid,frame_to_destroy,*evargs ): # here also get signature!
            # uid.set(addr)
            # frame_to_destroy.destroy()

            g1_table.set_cmd('toaddr', [g1_table, ['toaddr']],
                             self.get_addr_from_wallet)
            g1_table.set_cmd('sendfromaddr', [g1_table, ['sendfromaddr']],
                             self.get_addr_from_wallet)

            def send_request():
                localdb.set_last_addr_from(g1_table.get_value('sendfromaddr'),
                                           "'last_book_from_addr'")
                localdb.set_last_addr_from(g1_table.get_value('toaddr'),
                                           "'last_payment_to_addr'")

                tmpam = round(float(g1_table.get_value('amount')), 8)

                if tmpam > 100000000 or tmpam < 0.0001:
                    flexitable.showinfo(
                        'Amount not valid, please correct', 'Amount ' +
                        str(tmpam) + ' is not practical, please correct.')
                    return

                tmptoaddr = g1_table.get_value('toaddr')
                if tmptoaddr in ['', '...']:
                    flexitable.showinfo(
                        'Address missing',
                        'Please enter valid [Payment to address]')
                    return

                tmpfromaddr = g1_table.get_value('sendfromaddr')
                if tmpfromaddr in ['', '...']:
                    flexitable.showinfo(
                        'Address missing',
                        'Please enter valid [Send using] address')
                    return

                if len(g1_table.get_value('title')) > 64:
                    flexitable.showinfo(
                        'Title too long',
                        'Please correct request title to be less then 64 characters long.'
                    )
                    return

                tmpsignature = localdb.get_addr_to_hash(addr)

                memo_json = {
                    'amount': tmpam,
                    'toaddress': tmptoaddr,
                    'title': g1_table.get_value('title'),
                    'docuri': g1_table.get_value('docuri')
                }

                # add sign
                ddict = {
                    'fromaddr':
                    tmpfromaddr,
                    'to': [{
                        'z':
                        addr,
                        'a':
                        0.0001,
                        'm':
                        'PaymentRequest;' + json.dumps(memo_json) +
                        tmpsignature
                    }]
                }
                table = {}
                table['queue_waiting'] = [
                    localdb.set_que_waiting('send', jsonstr=json.dumps(ddict))
                ]
                idb = localdb.DB()
                idb.insert(table, [
                    'type', 'wait_seconds', 'created_time', 'command', 'json',
                    'id', 'status'
                ])

                formframe.destroy()

            g1_table.set_cmd('submit', [], send_request)
예제 #8
0
    def setaddrbook(self, parent_frame):

        global idb, grid_settings, form_grid, cur_addr

        frame0 = ttk.LabelFrame(parent_frame, text='Filter')
        frame0.grid(row=0, column=0, sticky="nsew")
        tmpdict = {}
        tmpdict['summary'] = [{
            'T': 'Combox',
            'uid': 'filter',
            'V': self.categories_filter()
        }]
        grid_filter = []
        grid_filter.append(tmpdict)

        filter_table = flexitable.FlexiTable(frame0, grid_filter)

        # addr book view left:
        frame1 = ttk.LabelFrame(parent_frame, text='Addresses list')
        frame1.grid(row=1, column=0, sticky="nsew")

        grid_settings = []
        tmpdict = {}
        tmpdict['head'] = [{
            'T': 'LabelC',
            'L': 'Usage'
        }, {
            'T': 'LabelC',
            'L': 'Category'
        }, {
            'T': 'LabelC',
            'L': 'Alias'
        }, {
            'T': 'LabelC',
            'L': 'Full address'
        }, {
            'T': 'LabelC',
            'L': 'Valid'
        }, {
            'T': 'LabelC',
            'L': 'View Key'
        }, {
            'T': 'LabelC',
            'L': 'Valid'
        }, {
            'T': 'LabelC',
            'L': ' '
        }, {
            'T': 'LabelC',
            'L': ' '
        }, {
            'T': 'LabelC',
            'L': ' '
        }, {
            'T': 'LabelC',
            'L': ' '
        }]

        grid_settings.append(tmpdict)

        idb = localdb.DB()
        cur_addr = []

        def update_grid(*argsevnts):
            global idb, grid_settings

            tmplen = len(grid_settings)
            if tmplen > 1:
                del grid_settings[1:tmplen]
                del cur_addr[0:]

            sel_addr_book = idb.select('addr_book', [
                'Category', 'Alias', 'Address', 'ViewKey', 'usage',
                'addr_verif', 'viewkey_verif'
            ],
                                       orderby=[{
                                           'usage': 'desc'
                                       }, {
                                           'Category': 'asc'
                                       }, {
                                           'Alias': 'asc'
                                       }])
            if len(sel_addr_book) > 0:

                filterv = filter_table.get_value('filter')

                for ii, rr in enumerate(sel_addr_book):
                    tmpdict = {}
                    visible = False
                    if filterv in [rr[0], 'All']:
                        visible = True

                    cur_addr.append(rr[2])

                    tmphasvk = False
                    uid_tmp = rr[2]
                    tmpnott = {
                        'T': 'LabelV',
                        'L': str(tmphasvk),
                        'uid': 'View' + str(uid_tmp),
                        'visible': visible
                    }
                    if rr[3].strip() != '':
                        tmphasvk = True
                        tmpnott = {
                            'T': 'LabelV',
                            'L': str(tmphasvk),
                            'uid': 'View' + str(uid_tmp),
                            'visible': visible,
                            'tooltip': rr[3].strip()
                        }

                    addrvalid = 'Waiting'
                    if rr[5] == -1:
                        addrvalid = 'No'
                    elif rr[5] == 1:
                        addrvalid = 'Yes'

                    viewk_valid = 'None'
                    if rr[6] == -1:
                        viewk_valid == 'No'
                    elif rr[6] == -1:
                        viewk_valid = 'Yes'
                    elif rr[6] == 0:
                        viewk_valid = 'Waiting'

                    tmpdict[uid_tmp] = [{
                        'T': 'LabelV',
                        'L': str(rr[4]),
                        'uid': 'Usage' + str(uid_tmp),
                        'visible': visible
                    }, {
                        'T': 'LabelV',
                        'L': rr[0],
                        'uid': 'Category' + str(uid_tmp),
                        'visible': visible
                    }, {
                        'T': 'LabelV',
                        'L': rr[1],
                        'uid': 'Alias' + str(uid_tmp),
                        'visible': visible
                    }, {
                        'T': 'InputL',
                        'L': rr[2],
                        'uid': 'Address' + str(uid_tmp),
                        'visible': visible,
                        'width': 24
                    }, {
                        'T': 'LabelV',
                        'L': addrvalid,
                        'uid': 'AddressValid' + str(uid_tmp),
                        'visible': visible
                    }, tmpnott, {
                        'T': 'LabelV',
                        'L': viewk_valid,
                        'uid': 'ViewKeyValid' + str(uid_tmp),
                        'visible': visible
                    }, {
                        'T': 'Button',
                        'L': 'Edit',
                        'uid': 'edit' + str(uid_tmp),
                        'visible': visible
                    }, {
                        'T': 'Button',
                        'L': 'Del.',
                        'uid': 'delete' + str(uid_tmp),
                        'visible': visible,
                        'tooltip': 'Delete record'
                    }, {
                        'T': 'Button',
                        'L': 'Copy',
                        'uid': 'copy' + str(uid_tmp),
                        'visible': visible
                    }, {
                        'T': 'Button',
                        'L': 'Send to',
                        'uid': 'sendto' + str(uid_tmp),
                        'visible': visible
                    }, {
                        'T': 'Button',
                        'L': 'RP',
                        'uid': 'rp' + str(uid_tmp),
                        'visible': visible,
                        'tooltip': 'Request payment from'
                    }]
                    grid_settings.append(tmpdict)

        update_grid()

        main_table = flexitable.FlexiTable(frame1, grid_settings)

        def update_filter(update_fun, *someargs):
            global grid_settings
            update_grid()
            main_table.update_frame(grid_settings, -1)
            update_fun()

        # form for edit and add:
        frame2 = ttk.LabelFrame(
            parent_frame, text='Add/edit form'
        )  #.grid(row=0,column=0,columnspan=3,sticky="nsew") #pack(fill='x')
        frame2.grid(row=1, column=1, sticky="nsew")
        form_grid = []
        init_form = [{
            'T': 'Button',
            'L': 'Import',
            'uid': 'import'
        }, {
            'T': 'LabelC',
            'L': 'Category'
        }, {
            'T': 'InputL',
            'uid': 'cat',
            'width': 32
        }, {
            'T': 'LabelC',
            'L': 'Alias'
        }, {
            'T': 'InputL',
            'uid': 'alia'
        }, {
            'T': 'LabelC',
            'L': 'Full address'
        }, {
            'T': 'InputL',
            'uid': 'addr',
            'width': 32
        }, {
            'T': 'LabelC',
            'L': 'View key'
        }, {
            'T': 'InputL',
            'uid': 'viewkey',
            'width': 32
        }, {
            'T': 'Button',
            'L': 'Save',
            'uid': 'enter'
        }]

        for ii, inf in enumerate(init_form):
            tmpdict = {}
            tmpdict[ii] = [inf]

            form_grid.append(tmpdict)

        form_table = flexitable.FlexiTable(frame2, form_grid)

        # button functions:

        def delete_addr(uid, addr, alias, update_fun):
            global idb, grid_settings

            tf = flexitable.msg_yes_no(
                'Delete from address book?',
                'Please confirm to delete address\n\n' + addr +
                '\n\nof alias\n\n' + alias + '\n')

            if tf:
                idb.delete_where('addr_book',
                                 {'Address': ['=', "'" + addr + "'"]})
                update_grid()
                main_table.update_frame(grid_settings, -1)
                update_fun()

        def edit_addr(uid, addr, alias, category,
                      viewkey):  # load data to form
            global idb, form_grid

            form_table.set_textvariable('cat', category)
            form_table.set_textvariable('alia', alias)
            form_table.set_textvariable('addr', addr)
            form_table.set_textvariable('viewkey', viewkey)

        def increment_usage(addr, update_fun):  # when copy or sendto
            global idb, grid_settings
            sel_addr_book = idb.select('addr_book', ['usage'],
                                       {'Address': ['=', "'" + addr + "'"]})
            table = {}
            table['addr_book'] = [{'usage': int(sel_addr_book[0][0]) + 1}]
            idb.upsert(table, ['usage'], {'Address': ['=', "'" + addr + "'"]})

            update_grid()
            main_table.update_frame(grid_settings, -1)
            update_fun()

        def subcopy(main_table, addr, update_fun):

            flexitable.copy(main_table, addr)
            increment_usage(addr, update_fun)

        def subsendto(addr, update_fun, sendto_fun):
            sendto_fun(addr)
            increment_usage(addr, update_fun)

        # json to string {'amount':, 'toaddr':,title:'','docuri':}
        # todo defaut send to addr
        # submit action
        # title max length 64
        def request_payment(alias, addr, update_fun, sendto_fun):

            formframe = Toplevel()
            formframe.title('Request payment from ' + alias)
            obligatory = ttk.Frame(formframe)
            obligatory.grid(row=0, column=0, sticky='NW')
            grid1 = []
            grid1.append({
                'line1': [{
                    'T': 'LabelC',
                    'L': 'Obligatory:'
                }, {
                    'T': 'LabelE'
                }]
            })
            grid1.append({
                'amount': [{
                    'T': 'LabelC',
                    'L': 'Request amount'
                }, {
                    'T': 'InputFloat',
                    'L': '0',
                    'uid': 'amount',
                    'width': 32
                }]
            })
            select = localdb.get_last_addr_from("'last_payment_to_addr'")
            grid1.append({
                'toaddress': [{
                    'T': 'LabelC',
                    'L': 'Payment to address'
                }, {
                    'T': 'Button',
                    'L': select,
                    'uid': 'toaddr',
                    'width': 32
                }]
            })
            grid1.append({
                'line1': [{
                    'T': 'LabelC',
                    'L': 'Optional:'
                }, {
                    'T': 'LabelE'
                }]
            })
            grid1.append({
                'title': [{
                    'T': 'LabelC',
                    'L': 'Title'
                }, {
                    'T': 'InputL',
                    'L': 'Payment request for invoice nr ',
                    'uid': 'title',
                    'width': 32
                }]
            })
            grid1.append({
                'docuri': [{
                    'T': 'LabelC',
                    'L': 'Document URI'
                }, {
                    'T': 'InputL',
                    'uid': 'docuri',
                    'width': 32
                }]
            })
            select = localdb.get_last_addr_from("'last_book_from_addr'")
            grid1.append({
                'sendfrommyaddr': [{
                    'T': 'LabelC',
                    'L': 'Send using'
                }, {
                    'T': 'Button',
                    'L': select,
                    'uid': 'sendfromaddr',
                    'width': 32
                }]
            })
            grid1.append({
                'submit': [{
                    'T': 'Button',
                    'L': 'Send request',
                    'span': 2,
                    'uid': 'submit'
                }, {}]
            })

            g1_table = flexitable.FlexiTable(obligatory, grid1)

            # def selecting_addr_from_book_set_and_destroy_sending( addr,uid,frame_to_destroy,*evargs ): # here also get signature!
            # uid.set(addr)
            # frame_to_destroy.destroy()

            g1_table.set_cmd('toaddr', [g1_table, ['toaddr']],
                             self.get_addr_from_wallet)
            g1_table.set_cmd('sendfromaddr', [g1_table, ['sendfromaddr']],
                             self.get_addr_from_wallet)

            def send_request():
                localdb.set_last_addr_from(g1_table.get_value('sendfromaddr'),
                                           "'last_book_from_addr'")
                localdb.set_last_addr_from(g1_table.get_value('toaddr'),
                                           "'last_payment_to_addr'")

                tmpam = round(float(g1_table.get_value('amount')), 8)

                if tmpam > 100000000 or tmpam < 0.0001:
                    flexitable.showinfo(
                        'Amount not valid, please correct', 'Amount ' +
                        str(tmpam) + ' is not practical, please correct.')
                    return

                tmptoaddr = g1_table.get_value('toaddr')
                if tmptoaddr in ['', '...']:
                    flexitable.showinfo(
                        'Address missing',
                        'Please enter valid [Payment to address]')
                    return

                tmpfromaddr = g1_table.get_value('sendfromaddr')
                if tmpfromaddr in ['', '...']:
                    flexitable.showinfo(
                        'Address missing',
                        'Please enter valid [Send using] address')
                    return

                if len(g1_table.get_value('title')) > 64:
                    flexitable.showinfo(
                        'Title too long',
                        'Please correct request title to be less then 64 characters long.'
                    )
                    return

                tmpsignature = localdb.get_addr_to_hash(addr)

                memo_json = {
                    'amount': tmpam,
                    'toaddress': tmptoaddr,
                    'title': g1_table.get_value('title'),
                    'docuri': g1_table.get_value('docuri')
                }

                # add sign
                ddict = {
                    'fromaddr':
                    tmpfromaddr,
                    'to': [{
                        'z':
                        addr,
                        'a':
                        0.0001,
                        'm':
                        'PaymentRequest;' + json.dumps(memo_json) +
                        tmpsignature
                    }]
                }
                table = {}
                table['queue_waiting'] = [
                    localdb.set_que_waiting('send', jsonstr=json.dumps(ddict))
                ]
                idb = localdb.DB()
                idb.insert(table, [
                    'type', 'wait_seconds', 'created_time', 'command', 'json',
                    'id', 'status'
                ])

                formframe.destroy()

            g1_table.set_cmd('submit', [], send_request)
            # submit button - create json and send it

            # table={}
            # if asap:
            # table['queue_waiting']=[localdb.set_que_waiting('send',jsonstr=json.dumps(ddict) ) ]
            # else:
            # table['queue_waiting']=[localdb.set_que_waiting('send',jsonstr=json.dumps(ddict) , wait_seconds=WAIT_S) ]

            # if table['queue_waiting'][0]['wait_seconds']==0:
            # self.queue_com.put([ table['queue_waiting'][0]['id'],'Sending\n',self.message_asap_tx_done])

        # buttons commands for main grid:
        def update_buttons():
            global idb, form_grid, grid_settings

            for x1 in grid_settings:

                for kk, vv in x1.items():
                    if kk == 'head':
                        continue

                    addr = main_table.get_value('Address' + str(kk))
                    alias = main_table.get_value('Alias' + str(kk))
                    categ = main_table.get_value('Category' + str(kk))
                    viewk = ''

                    if 'tooltip' in vv[5]:
                        viewk = vv[5][
                            'tooltip']  #main_table.get_value('View'+str(kk) )

                    edit_uid = 'edit' + str(kk)
                    main_table.set_cmd(edit_uid,
                                       [kk, addr, alias, categ, viewk],
                                       edit_addr)

                    del_uid = 'delete' + str(
                        kk)  # remove from db and update view
                    main_table.set_cmd(del_uid,
                                       [kk, addr, alias, update_buttons],
                                       delete_addr)

                    copy_uid = 'copy' + str(
                        kk)  # remove from db and update view
                    main_table.set_cmd(copy_uid,
                                       [main_table, addr, update_buttons],
                                       subcopy)

                    send_uid = 'sendto' + str(kk)
                    main_table.set_cmd(
                        send_uid,
                        [addr, update_buttons, self.wds.send_to_addr],
                        subsendto)

                    # request payment
                    # print('request payment')
                    rp_uid = 'rp' + str(kk)
                    main_table.set_cmd(
                        rp_uid,
                        [alias, addr, update_buttons, self.wds.send_to_addr],
                        request_payment)

        update_buttons()

        filter_table.bind_combox_cmd('filter', [update_buttons], update_filter)

        def update_filter_values():
            # global wds
            tmpdict = {}
            tmpdict['summary'] = [{
                'T': 'Combox',
                'uid': 'filter',
                'V': self.categories_filter()
            }]
            grid_filter = []
            grid_filter.append(tmpdict)
            filter_table.update_frame(grid_filter)

        def save_new():
            global idb, form_grid, grid_settings
            table = {}
            tmpaddr = form_table.get_value('addr').strip()

            if tmpaddr == '':
                return

            tmpvk = form_table.get_value('viewkey').strip()
            tmpcat = form_table.get_value('cat').strip()
            tmpalia = form_table.get_value('alia').strip()

            sel_addr_book = idb.select(
                'addr_book', ['ViewKey', 'addr_verif', 'viewkey_verif'],
                {'Address': ['=', "'" + tmpaddr + "'"]})
            tmpaddr_valid = 0
            tmpvk_valid = -2
            if len(sel_addr_book) > 0:
                if sel_addr_book[0][0] != tmpvk and tmpvk != '':
                    tmpvk_valid = 0
                else:
                    tmpaddr_valid = sel_addr_book[0][1]
                    tmpvk_valid = sel_addr_book[0][2]

            if tmpaddr in cur_addr:
                table = {}
                table['addr_book'] = [{
                    'Category': tmpcat,
                    'Alias': tmpalia,
                    'Address': tmpaddr,
                    'ViewKey': tmpvk,
                    'addr_verif': tmpaddr_valid,
                    'viewkey_verif': tmpvk_valid
                }]
                idb.upsert(table, [
                    'Category', 'Alias', 'Address', 'ViewKey', 'addr_verif',
                    'viewkey_verif'
                ], {'Address': ['=', "'" + tmpaddr + "'"]})

                if tmpvk_valid == 0:  # upsert to prevent double action
                    table = {}
                    tmpjson = json.dumps({'addr': tmpaddr, 'viewkey': tmpvk})
                    table['queue_waiting'] = [
                        localdb.set_que_waiting(command='import_view_key',
                                                jsonstr=tmpjson,
                                                wait_seconds=0)
                    ]
                    idb.upsert(
                        table, [
                            'type', 'wait_seconds', 'created_time', 'command',
                            'json', 'id', 'status'
                        ], {
                            'command': ['=', "'" + import_view_key + "'"],
                            'json': ['=', "'" + tmpjson + "'"]
                        })
            else:
                table['addr_book'] = [{
                    'Category': tmpcat,
                    'Alias': tmpalia,
                    'Address': tmpaddr,
                    'ViewKey': tmpvk,
                    'usage': 0,
                    'addr_verif': tmpaddr_valid,
                    'viewkey_verif': tmpvk_valid
                }]
                idb.insert(table, [
                    'Category', 'Alias', 'Address', 'ViewKey', 'usage',
                    'addr_verif', 'viewkey_verif'
                ])

                table = {}  # valid addr
                table['queue_waiting'] = [
                    localdb.set_que_waiting(command='validate_addr',
                                            jsonstr=json.dumps(
                                                {'addr': tmpaddr}),
                                            wait_seconds=0)
                ]
                idb.insert(table, [
                    'type', 'wait_seconds', 'created_time', 'command', 'json',
                    'id', 'status'
                ])

                if tmpvk != '':
                    table = {}
                    tmpjson = json.dumps({'addr': tmpaddr, 'viewkey': tmpvk})
                    table['queue_waiting'] = [
                        localdb.set_que_waiting(command='import_view_key',
                                                jsonstr=tmpjson,
                                                wait_seconds=0)
                    ]
                    idb.insert(table, [
                        'type', 'wait_seconds', 'created_time', 'command',
                        'json', 'id', 'status'
                    ])

                # idb.upsert(table,[ 'Category','Alias','Address','ViewKey','usage'],{'Address':['=',"'"+tmpaddr+"'"]})

            form_table.set_textvariable('cat', '')
            form_table.set_textvariable('alia', '')
            form_table.set_textvariable('addr', '')
            form_table.set_textvariable('viewkey', '')
            update_grid()
            main_table.update_frame(grid_settings, -1)
            # print('674\n',grid_settings)
            update_buttons()

            update_filter_values()

        form_table.set_cmd('enter', [], save_new)

        # open dialog to select file
        # 2 types : zaddr or viewkey
        def import_z():
            global zpath
            zpath = flexitable.get_file_dialog(
                "Select file with z-address or view key")
            if zpath == None:
                return

            tmpval = []

            # if len(tmpval)>0:
            def whilewaiting(tmpval2):
                global zpath

                if tmpval2[0] == ' ':
                    return
                cc = aes.Crypto()

                decr_val = cc.aes_decrypt_file(path1=zpath,
                                               path2=None,
                                               password=tmpval2[0])

                try:
                    ddi = json.loads(decr_val)

                    if 'viewkey' in ddi:
                        form_table.set_textvariable('cat', 'ViewKey')
                        form_table.set_textvariable('addr', ddi['addr'])
                        form_table.set_textvariable('viewkey', ddi['viewkey'])
                    else:
                        form_table.set_textvariable('addr', ddi['addr'])

                except:
                    flexitable.showinfo(
                        'Could not decrypt file', 'File ' + zpath +
                        ' does not contain encrypted address or view key or you have wrong password!'
                    )

            flexitable.ask_password(tmpval, 'Decrypting file',
                                    '\n Decrypting file ' + zpath +
                                    '\n\nEnter password\n',
                                    whilewaiting)  # set password if needed ?

        form_table.set_cmd('import', [], import_z)
예제 #9
0
    def get_addr_from_book(self, uid, set_and_destroy, *evargs):

        selframe = Toplevel()  #tk.Tk()
        selframe.title('Select address ' + str(uid))
        filter_frame = ttk.LabelFrame(selframe, text='Filter')
        filter_frame.grid(row=0, column=0)

        filtbox = ttk.Combobox(filter_frame,
                               textvariable='All',
                               values=self.categories_filter(),
                               state="readonly")
        filtbox.current(0)
        filtbox.pack()
        global grid_lol_select
        grid_lol_select = []
        tmpdict = {}
        tmpdict['head'] = [{}, {
            'T': 'LabelC',
            'L': 'Usage'
        }, {
            'T': 'LabelC',
            'L': 'Category'
        }, {
            'T': 'LabelC',
            'L': 'Alias'
        }, {
            'T': 'LabelC',
            'L': 'Full address'
        }]
        grid_lol_select.append(tmpdict)

        def update_grid(*argsevnts):
            global grid_lol_select

            tmplen = len(grid_lol_select)
            if tmplen > 1:
                del grid_lol_select[1:tmplen]

            idb = localdb.DB()
            sel_addr_book = idb.select(
                'addr_book', ['Category', 'Alias', 'Address', 'usage'],
                orderby=[{
                    'usage': 'desc'
                }, {
                    'Category': 'asc'
                }, {
                    'Alias': 'asc'
                }])

            if len(sel_addr_book) > 0:

                filterv = filtbox.get()

                for ii, rr in enumerate(sel_addr_book):
                    tmpdict = {}
                    visible = False
                    if filterv in [rr[0], 'All']:
                        visible = True

                    tmpdict[ii] = [{
                        'T': 'Button',
                        'L': 'Select',
                        'uid': 'select' + str(ii),
                        'visible': visible
                    }, {
                        'T': 'LabelV',
                        'L': str(rr[3]),
                        'uid': 'Usage' + str(ii),
                        'visible': visible
                    }, {
                        'T': 'LabelV',
                        'L': rr[0],
                        'uid': 'Category' + str(ii),
                        'visible': visible
                    }, {
                        'T': 'LabelV',
                        'L': rr[1],
                        'uid': 'Alias' + str(ii),
                        'visible': visible
                    }, {
                        'T': 'LabelV',
                        'L': rr[2],
                        'uid': 'Address' + str(ii),
                        'visible': visible
                    }]
                    grid_lol_select.append(tmpdict)

        update_grid()
        list_frame = ttk.LabelFrame(selframe, text='Addresses list')
        list_frame.grid(row=1, column=0)
        select_table = flexitable.FlexiTable(list_frame, grid_lol_select)

        for ij, ar in enumerate(grid_lol_select):
            if ij < 1: continue
            for ki, vi in ar.items():

                select_table.set_cmd(
                    vi[0]['uid'], [vi[4]['L'], uid, selframe],
                    set_and_destroy)  # print to master and destroy ?

        def update_filter(*someargs):
            global grid_lol_select
            update_grid()
            select_table.update_frame(grid_lol_select)

        filtbox.bind("<<ComboboxSelected>>", update_filter)
예제 #10
0
    def __init__(self, parent_frame, wds):
        global idb

        self.grid_settings = []

        ################ PASS CHANGE

        frame0 = ttk.LabelFrame(parent_frame, text='Password change')
        frame0.grid(row=0, column=0, sticky="nsew")

        tmpdict = {}
        tmpdict['pass_change'] = [{
            'T': 'LabelC',
            'L': 'Current password: '******'T': 'InputL',
            'L': '',
            'uid': 'old',
            'width': 16
        }, {
            'T': 'LabelC',
            'L': 'New password: '******'T': 'InputL',
            'L': '',
            'uid': 'new',
            'width': 16
        }, {
            'T': 'Button',
            'L': 'Change',
            'uid': 'enter',
            'width': 8
        }]
        grid_pass = []
        grid_pass.append(tmpdict)

        self.pass_table = flexitable.FlexiTable(
            frame0,
            grid_pass)  # +++ update command filter after each iteration

        def clear_change_info(*evargs):
            newpass = self.pass_table.get_value('new').strip()
            wds.password = newpass
            # clear
            self.pass_table.set_textvariable('new', '')
            self.pass_table.set_textvariable('old', '')
            # info

            messagebox.showinfo(
                "Password changed",
                "You have new password! Leading and trailing spaces where removed from the password to avoid mistakes."
            )

        self.pass_table.set_cmd('enter', [], clear_change_info)

        ################ DB maintenance / clear old tasks {'total_chars':total_chars, 'total_rows':rowsii, 'older_chars':older_chars, 'old_rows':old_rows}

        idb = localdb.DB()

        frame1 = ttk.LabelFrame(parent_frame, text='DB maintenance')
        frame1.grid(row=0, column=1, sticky="nsew")

        def update_db_info():
            global idb

            grid_db = []

            tmpsize = idb.table_size('jsons')
            tmpdict = {}
            tmpdict['jsons'] = [{
                'uid':
                '4',
                'T':
                'LabelV',
                'L':
                '[jsons] table size: ' + str(tmpsize['total_chars']) +
                ' chars ' + str(tmpsize['total_rows']) + ' rows '
            }]
            grid_db.append(tmpdict)

            tmpsize = idb.table_size('tx_history')
            tmpdict = {}
            tmpdict['tx_history'] = [{
                'uid':
                '2',
                'T':
                'LabelV',
                'L':
                '[tx_history] table size: ' + str(tmpsize['total_chars']) +
                ' chars ' + str(tmpsize['total_rows']) + ' rows '
            }]
            grid_db.append(tmpdict)

            tmpsize = idb.table_size('notifications')
            tmpdict = {}
            tmpdict['db_clear_old_notif'] = [{
                'uid':
                '3',
                'T':
                'LabelV',
                'L':
                '[notifications] table size: ' + str(tmpsize['total_chars']) +
                ' chars ' + str(tmpsize['total_rows']) + ' rows '
            }]
            grid_db.append(tmpdict)
            tmpdict = {}
            tmpdict['db_clear_old_notif2'] = [{
                'T': 'Button',
                'L': 'Delete all notifications',
                'uid': 'del_notif'
            }]
            grid_db.append(tmpdict)

            tmpsize = idb.table_size('queue_done')
            tmpdict = {}
            tmpdict['db_clear_old_tasks'] = [{
                'uid':
                '0',
                'T':
                'LabelV',
                'L':
                'Tasks history table size: ' + str(tmpsize['total_chars']) +
                ' chars ' + str(tmpsize['total_rows']) + ' rows '
            }]
            grid_db.append(tmpdict)
            tmpdict = {}
            tmpdict['db_clear_old_tasks1'] = [{
                'uid':
                '1',
                'T':
                'LabelV',
                'L':
                'Older then 1 month: ' + str(tmpsize['older_chars']) +
                ' chars ' + str(tmpsize['old_rows']) + ' rows '
            }]
            grid_db.append(tmpdict)
            tmpdict = {}
            tmpdict['db_clear_old_tasks2'] = [{
                'T': 'Button',
                'L': 'Delete old tasks',
                'uid': 'del'
            }]
            grid_db.append(tmpdict)

            return grid_db

        grid_db = update_db_info()

        self.db_table = flexitable.FlexiTable(frame1, grid_db)

        def delete_old(tname, datetime_colname, ddays, *evargs):
            global idb
            idb.delete_old(tname, datetime_colname, ddays)
            self.db_table.update_frame(update_db_info())

            self.db_table.set_cmd('del', ['queue_done', 'created_time', 31],
                                  delete_old)
            self.db_table.set_cmd('del_notif',
                                  ['notifications', 'datetime', 0], delete_old)

        self.db_table.set_cmd('del', ['queue_done', 'created_time', 31],
                              delete_old)
        self.db_table.set_cmd('del_notif', ['notifications', 'datetime', 0],
                              delete_old)
예제 #11
0
    def __init__(
            self, parent_frame, notebook_parent,
            addr_book):  # notebook_parent : in case of new msg - adj tab title
        self.update_in_progress = False
        self.notebook_parent = notebook_parent
        self.max_block = 0
        self.proc_inout()

        self.addr_book = addr_book

        frame0 = ttk.LabelFrame(parent_frame, text='Options')
        frame0.grid(row=0, column=0, sticky="nsew")

        tmpdict = {}
        tmpdict['filters'] = [
            {
                'T': 'LabelC',
                'L': 'Threads: '
            },
            {
                'T': 'Combox',
                'uid': 'thr',
                'V': ['Last 7 days', 'Last 30 days', 'All']
            },
            {
                'T': 'LabelC',
                'L': 'Messages: '
            },
            {
                'T': 'Combox',
                'uid': 'msg',
                'V': ['Last 10', 'Last 100', 'All']
            }
            # , {'T':'Button', 'L':'Reply', 'uid':'reply'}
            ,
            {
                'T': 'Button',
                'L': 'New message',
                'uid': 'newmsg',
                'width': 13
            }
        ]
        grid_filter = []
        grid_filter.append(tmpdict)

        self.filter_table = flexitable.FlexiTable(
            frame0,
            grid_filter)  # +++ update command filter after each iteration

        self.filter_table.bind_combox_cmd('thr', [], self.update_tread_frame)
        self.filter_table.bind_combox_cmd('msg', [], self.update_msg_frame)
        # send_reply
        # self.filter_table.set_cmd('reply',['r' ], self.send_reply)
        self.filter_table.set_cmd('newmsg', ['s'], self.send_reply)

        self.grid_threads = []
        self.grid_threads_msg = {}
        self.thr_ord = []

        frame1 = ttk.LabelFrame(parent_frame, text='Threads')
        frame1.grid(row=1, column=0, sticky="nsew")
        self.frame1 = frame1

        tmpdict = {}
        tmpdict['head'] = [{
            'T': 'LabelC',
            'L': 'Correspondents'
        }  #, # alias or generic name
                           #{'T':'LabelC', 'L':'Action' }  # button view
                           ]

        self.grid_threads.append(tmpdict)
        self.update_threads()

        self.thr_table = flexitable.FlexiTable(frame1,
                                               self.grid_threads,
                                               min_canvas_width=200,
                                               force_scroll=True)
        self.set_actions()

        self.update_list()
        self.main_table = None
        if len(self.thr_ord) > 0:

            self.cur_uid = self.valid_uids[0]

            self.main_table = flexitable.FlexiTable(
                frame1,
                self.grid_threads_msg[self.cur_uid],
                min_canvas_width=800,
                force_scroll=True)
            self.set_edit_alias_action(self.cur_uid)

        self.updating_threads = False
        self.updating_chat = False
예제 #12
0
    def send_reply(self, *args):
        global tmpaddr
        selframe = Toplevel()
        selframe.title('Write message ')

        msg_grid = []
        tmpdict = {
            'from': [{
                'T': 'LabelC',
                'L': 'Select own address',
                'width': 19
            }, {
                'T': 'Button',
                'L': '...',
                'uid': 'selownadr',
                'width': 4
            }, {
                'T': 'LabelV',
                'L': '',
                'uid': 'ownaddr',
                'width': 80
            }]
        }
        msg_grid.append(tmpdict)

        tmpdict = {
            'to': [{
                'T': 'LabelC',
                'L': 'Select address to',
                'width': 19
            }, {
                'T': 'Button',
                'L': '...',
                'uid': 'seladr',
                'width': 4
            }, {
                'T': 'LabelV',
                'L': '',
                'uid': 'addr',
                'width': 80
            }]
        }

        tmpaddr = ''
        if args[0] == 'r' and hasattr(self, 'cur_addr'):
            tmpaddr = self.cur_addr
            tmpdict = {
                'to': [{
                    'T': 'LabelC',
                    'L': 'Replying to: ' + tmpaddr,
                    'width': 80
                }, {
                    'T': 'LabelE'
                }, {
                    'T': 'LabelE'
                }]
            }

        msg_grid.append(tmpdict)
        tmpdict = {
            'msg': [{
                'T': 'Text',
                'uid': 'msg',
                'span': 3,
                'height': 10,
                'width': 80,
                'L': ''
            }]
        }
        msg_grid.append(tmpdict)
        tmpdict = {
            'send': [{
                'T': 'Button',
                'L': 'Send',
                'uid': 'send',
                'width': 6
            }, {
                'T': 'LabelE'
            }, {
                'T': 'LabelE'
            }]
        }
        msg_grid.append(tmpdict)

        msg_table = flexitable.FlexiTable(selframe, msg_grid)

        last_addr = localdb.get_last_addr_from("'last_msg_from_addr'")

        if last_addr not in ['', '...']:
            msg_table.set_textvariable('ownaddr', last_addr)

        def send():
            global tmpaddr
            msg = msg_table.get_value('msg')
            if msg.strip() == '':
                return

            to = tmpaddr
            if tmpaddr == '':
                to = msg_table.get_value('addr')

            froma = msg_table.get_value('ownaddr')
            if froma == '':
                return

            got_bad_char, msg_arr = self.prep_msg(msg, to)

            if got_bad_char:
                return

            ddict = {'fromaddr': froma, 'to': []}  #
            for mm in msg_arr:
                ddict['to'].append({'z': to, 'a': 0.0001, 'm': mm})

            table = {}
            table['queue_waiting'] = [
                localdb.set_que_waiting('send', jsonstr=json.dumps(ddict))
            ]
            table['queue_waiting'][0]['type'] = 'message'

            idb = localdb.DB()
            idb.insert(table, [
                'type', 'wait_seconds', 'created_time', 'command', 'json',
                'id', 'status'
            ])

            # self.set_last_addr_from( froma)
            localdb.set_last_addr_from(froma, "'last_msg_from_addr'")
            selframe.destroy()

        msg_table.set_cmd('send', [], send)
        msg_table.set_cmd(
            'selownadr', [msg_table, ['ownaddr']],
            self.addr_book.get_addr_from_wallet
        )  # self.selecting_addr_from_book_set_and_destroy_sending,

        if tmpaddr == '':
            msg_table.set_cmd('seladr', [
                'addr', self.selecting_addr_from_book_set_and_destroy_sending
            ], self.addr_book.get_addr_from_book)
예제 #13
0
def setwallet(tabs0, app_password, autostart, queue_start_stop, queue_com,
              addit_frames):
    tabs1 = ttk.Notebook(tabs0)
    tabs1.pack(fill='both')
    tabs0.add(tabs1, text='Wallet')

    #########
    ######### SUBTAB 1 - Balance
    #########
    frame01 = ttk.Frame(tabs1, width=200, height=200)
    frame01.pack()  #fill='both'
    tabs1.add(frame01, text='Balance')

    frame01.columnconfigure(0, weight=1)
    frame01.columnconfigure(1, weight=1)

    ###
    ### FRAME 1 - blockchain status
    ###
    stat = ttk.LabelFrame(frame01, text='Blockchain status')
    stat.grid(row=0, column=1, sticky='nswe', padx=10, pady=5)

    stat_lab = StringVar()
    stat_lab.set('Blockchain off')
    ttk.Label(stat, textvariable=stat_lab).pack(side='left')

    startstop = StringVar()

    bstartstop = ttk.Button(stat, textvariable=startstop)
    bstartstop.pack(side='right', padx=10, pady=5)

    if autostart == 'yes':
        startstop.set('Stop blockchain')
        bstartstop.configure(state='disabled')
    else:
        startstop.set('Start blockchain')

    def togglestartstop(elem):
        if elem.get() == 'Stop blockchain':
            elem.set('Start blockchain')
            queue_start_stop.put({'cmd': 'stop_deamon'})

        else:
            elem.set('Stop blockchain')

            def restart(addrescan):
                if addrescan == 'No':
                    addrescan = False
                else:
                    addrescan = True

                queue_start_stop.put({
                    'cmd': 'start_deamon',
                    'addrescan': addrescan
                })

            flexitable.simple_opt_box("Rescan wallet?", ['No', 'Yes'], restart)

    bstartstop.configure(command=partial(togglestartstop, startstop))

    ###
    ### FRAME 2 - summary
    ### todo: save to db, add refresh,

    summary = ttk.LabelFrame(frame01, text='Summary')
    summary.grid(row=0, column=0, sticky='nsew', padx=10, pady=5)
    summary.columnconfigure(0, weight=1)

    global wds
    wds = WalDispSet(app_password, queue_com)

    grid_lol_wallet_sum = wds.prepare_summary_frame(True)

    wallet_summary_frame = flexitable.FlexiTable(summary, grid_lol_wallet_sum)

    ###
    ### FRAME 3 - wallet balances
    ###

    table = ttk.LabelFrame(
        frame01, text='Balance by address')  #, style='new.TLabelframe'
    table.grid(row=1, column=0, sticky='nsew', padx=10, pady=5)
    table.columnconfigure(0, weight=1)

    grid_lol3 = wds.get_header(False)

    wallet_details = flexitable.FlexiTable(table, grid_lol3, 600,
                                           True)  #params=None, grid_lol=None

    def save_wallet_display(opt, *evnt):
        global wds
        idb = localdb.DB()
        table = {}

        vv = wallet_summary_frame.get_value(opt.replace(
            'ing', ''))  # name similar to uid hence hack
        table['wallet_display'] = [{'option': opt, 'value': vv}]
        idb.upsert(table, ['option', 'value'],
                   {'option': ['=', "'" + opt + "'"]})

        while wds.is_locked():
            time.sleep(1)

        wds.lock_basic_frames()

        grid_lol_wallet_sum = wds.prepare_summary_frame()
        wallet_summary_frame.update_frame(grid_lol_wallet_sum)

        grid_lol3 = wds.prepare_byaddr_frame()
        wallet_details.update_frame(grid_lol3)
        wds.prepare_byaddr_button_cmd(grid_lol3, wallet_details)

        wds.unlock_basic_frames()

    wallet_summary_frame.bind_combox_cmd('sort', ['sorting'],
                                         save_wallet_display)
    wallet_summary_frame.bind_combox_cmd('round', ['rounding'],
                                         save_wallet_display)
    wallet_summary_frame.bind_combox_cmd('filter', ['filtering'],
                                         save_wallet_display)
    wallet_summary_frame.set_cmd('addaddr', [], wds.new_addr)  #'addaddr'
    wallet_summary_frame.set_cmd('export', [], wds.export_wallet)  #'addaddr'

    opt = wds.get_options(True)
    tmprounding = opt['rounding']  #self.get_rounding_str()
    tmpsorting = opt['sorting']  #self.get_sorting()
    tmpfiltering = opt['filtering']  #self.get_filtering()
    wallet_summary_frame.set_textvariable('round', tmprounding)
    wallet_summary_frame.set_textvariable('sort', tmpsorting)
    wallet_summary_frame.set_textvariable('filter', tmpfiltering)
    save_wallet_display('sorting')
    wallet_details.after(500, save_wallet_display, 'sorting')

    ###
    ### FRAME 4 - manual queue
    ###

    queue = ttk.LabelFrame(frame01,
                           text='Tasks queue')  #, style='new.TLabelframe'
    queue.grid(row=1, column=1, sticky='nswe', padx=10, pady=5)
    queue.columnconfigure(0, weight=1)

    # grid_lol4=wds.queue_header()
    # queue_status=None #flexitable.FlexiTable(queue,grid_lol4,400,True)

    def set_queue():
        global wds  #, queue_status
        grid_lol4 = wds.prepare_queue_frame(True)
        queue_status = flexitable.FlexiTable(queue, grid_lol4, 400,
                                             True)  #params=None, grid_lol=None
        wds.queue_frame_buttons(grid_lol4, queue_status)
        addit_frames['queue_status'] = queue_status

    queue.after(1000, set_queue)

    #########
    ######### SUBTAB 2 - Notifications
    #########
    frame_notif = ttk.Frame(tabs1, width=200, height=200)
    frame_notif.pack(fill='both', expand=True)
    tabs1.add(frame_notif, text='Notifications')
    global addrb
    addrb = addr_book.AddressBook(wds)

    def set_notif():
        global notif, addrb
        notif = Notifications(frame_notif, tabs1, addrb)
        addit_frames['notif'] = notif

    frame_notif.after(2000, set_notif)

    #########
    ######### SUBTAB 2 - History of transactions
    #########
    frame02 = ttk.Frame(tabs1, width=200, height=200)
    frame02.pack(fill='both', expand=True)
    tabs1.add(frame02, text='TX history')

    # filter type, command, dates: last 24h default, last week, last month, last 12 months, all

    def set_history():
        global txhi
        txhi = TransactionsHistory(frame02)
        addit_frames['txhi'] = txhi

    frame02.after(2000, set_history)

    #########
    ######### SUBTAB 2 - History of tasks
    #########
    tt11 = time.time()
    frame03 = ttk.Frame(tabs1, width=200, height=200)
    frame03.pack(fill='both', expand=True)
    tabs1.add(frame03, text='Tasks history')

    def set_tasks():
        global tahi
        # tahi=TransactionsHistory(frame03)
        tahi = TasksHistory(frame03)

        addit_frames['tahi'] = tahi

        def _on_resize(event):

            sx = float(event.width) / frame01.winfo_reqwidth()
            sy = float(event.height) / frame01.winfo_reqheight()
            wallet_details.resize_canvas(sx, sy)

            tahi.main_table.resize_canvas(sx, sy)

        frame01.bind("<Configure>", _on_resize)

    frame03.after(3000, set_tasks)

    ###
    ### START DEAMON
    ###

    #########
    ######### SUBTAB 3 - Settings
    #########
    frame_settings = ttk.Frame(tabs1)
    frame_settings.pack(fill='both', expand=True)
    tabs1.add(frame_settings, text='Settings')

    sett = Settings(frame_settings, wds)

    return stat_lab, bstartstop, wallet_summary_frame, wallet_details, wds, addrb  #,queue_status,tahi,txhi,notif
예제 #14
0
def ask_paths():  # read from db if possible

    idb = localdb.DB('init.db')

    preset = []
    tt = idb.select('init_settings',
                    columns=["komodo", "datadir",
                             "start_chain"])  #,"password_on"
    if len(tt) > 0:  #idb.check_table_exist('init_settings'):

        for t in tt[0]:  # single row only
            preset.append(t)
    else:

        preset = ['', '', 'no']
        # preset win path
        curusr = getpass.getuser()
        curpath = os.getcwd().split(
            '\\')  #C:\Users\zxcv\AppData\Roaming\Komodo\PIRATE
        templatepath = curpath[0] + '/' + '/'.join(
            ['Users', curusr, 'AppData', 'Roaming', 'Komodo', 'PIRATE'])

        if sys.platform == 'win32' and os.path.exists(templatepath):
            preset[1] = templatepath
        elif os.path.exists('/home/' + curusr + '/komodo/PIRATE'):
            preset[1] = '/home/' + curusr + '/komodo/PIRATE'

    rootframe = tk.Tk()
    rootframe.title('Enter zUnderNet')

    frame_settings = ttk.LabelFrame(rootframe, text='Initial settings')
    frame_settings.pack()

    automate_rowids = [
        [{
            'T': 'LabelC',
            'L':
            'Set proper paths, otherwise the deamon may freez and you may need to kill the process manually.',
            'span': 3,
            'width': 120
        }, {}, {}],
        [{
            'T': 'LabelC',
            'L': 'Select deamon and cli path (komodod and komodo-cli inside)'
        }, {
            'T': 'Button',
            'L': 'Komodo path:',
            'uid': 'p1'
        }, {
            'T': 'LabelV',
            'L': preset[0],
            'uid': 'deamon'
        }],
        [{
            'T': 'LabelC',
            'L': 'Select data directory'
        }, {
            'T': 'Button',
            'L': 'Data dir path:',
            'uid': 'p2'
        }, {
            'T': 'LabelV',
            'L': preset[1],
            'uid': 'data'
        }],
        [{
            'T': 'LabelC',
            'L': 'Start blockchain'
        }, {
            'T': 'Combox',
            'V': ['no', 'yes'],
            'uid': 'cs2'
        }, {
            'T': 'LabelE'
        }],
        # [{'T':'LabelC', 'L':'Set password protection'}, {'T':'Combox','V':['no','yes'],'uid':'cs1'}, {} ],
        [{
            'T': 'Button',
            'L': 'Confirm',
            'uid': 'conf',
            'span': 3,
            'width': 120
        }, {}, {}]
    ]  #, 'width':128

    grid_settings = []
    for ij, ar in enumerate(automate_rowids):
        tmpdict = {}
        tmpdict[ij] = ar
        grid_settings.append(tmpdict)

    settings = flexitable.FlexiTable(frame_settings,
                                     grid_settings)  #, scale_width=False

    settings.set_cmd('p1', ['deamon'], flexitable.setdir)
    settings.set_cmd('p2', ['data'], flexitable.setdir)
    settings.set_cmd('conf', ['deamon', 'data', 'cs2', idb, rootframe],
                     update_paths)  # save to db
    # settings.set_textvariable('cs1',preset[2])
    settings.set_textvariable('cs2', preset[2])

    # print('zxc')

    def on_closing():
        rootframe.destroy()
        exit()

    rootframe.protocol("WM_DELETE_WINDOW", on_closing)
    rootframe.mainloop()
예제 #15
0
    def __init__(self, parent_frame):
        self.grid_settings = []
        self.update_in_progress = False

        idb = localdb.DB()

        frame0 = ttk.LabelFrame(parent_frame, text='Filter')
        frame0.grid(row=0, column=0, sticky="nsew")

        tmpdict = {}
        tmpdict['filters'] = [{
            'T': 'LabelC',
            'L': 'Category: '
        }, {
            'T': 'Combox',
            'uid': 'category',
            'V': ['All', 'send', 'merge', 'other']
        }, {
            'T': 'LabelC',
            'L': 'Type: '
        }, {
            'T': 'Combox',
            'uid': 'type',
            'V': ['All', 'in', 'out']
        }, {
            'T': 'LabelC',
            'L': 'Last: '
        }, {
            'T': 'Combox',
            'uid': 'last',
            'V': ['24h', 'week', 'month', '12 months', 'All']
        }, {
            'T': 'LabelC',
            'L': 'Status: '
        }, {
            'T': 'Combox',
            'uid': 'status',
            'V': ['All', 'sent', 'received', 'notarized']
        }]
        grid_filter = []
        grid_filter.append(tmpdict)

        self.filter_table = flexitable.FlexiTable(frame0, grid_filter)

        # addr book view left:
        frame1 = ttk.LabelFrame(parent_frame, text='Transactions list')
        frame1.grid(row=1, column=0, sticky="nsew")

        tmpdict = {}
        tmpdict['head'] = [{
            'T': 'LabelC',
            'L': 'Category'
        }, {
            'T': 'LabelC',
            'L': 'Type'
        }, {
            'T': 'LabelC',
            'L': 'Status'
        }, {
            'T': 'LabelC',
            'L': 'Block'
        }, {
            'T': 'LabelC',
            'L': 'Date time'
        }, {
            'T': 'LabelC',
            'L': 'Amount'
        }, {
            'T': 'LabelC',
            'L': 'From'
        }, {
            'T': 'LabelC',
            'L': 'To'
        }, {
            'T': 'LabelC',
            'L': 'txid'
        }]

        self.grid_settings.append(tmpdict)

        self.update_list()

        self.main_table = flexitable.FlexiTable(frame1,
                                                self.grid_settings,
                                                min_canvas_width=1200,
                                                force_scroll=True)

        self.filter_table.bind_combox_cmd('category', [],
                                          self.update_history_frame)
        self.filter_table.bind_combox_cmd('type', [],
                                          self.update_history_frame)
        self.filter_table.bind_combox_cmd('status', [],
                                          self.update_history_frame)
        self.filter_table.bind_combox_cmd('last', [],
                                          self.update_history_frame)