Skip to content

Commit aa41550

Browse files
authored
Fixed a lot of bugs
1 parent 4774b47 commit aa41550

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

main.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
button_url2=config['Main']['button_url2']
2929

3030
#####################
31-
global rpcconnect
32-
rpcconnect=False
33-
start_time=time.time()
3431
cd = dir_path = os.path.dirname(os.path.realpath(__file__))
3532
# begin wxGlade: dependencies
3633
# end wxGlade
@@ -318,9 +315,8 @@ def get_textbox_url_btn2(self, evt):
318315

319316

320317
def updatefunc(self, evt):
321-
global rpcconnect
322318
global RPC
323-
319+
RPC.clear()
324320

325321
client_id_ent = (str(self.text_ctrl_1.GetValue()))
326322
details = (str(self.text_ctrl_2.GetValue()))
@@ -337,7 +333,9 @@ def updatefunc(self, evt):
337333

338334
print(client_id)
339335

340-
if rpcconnect==False:
336+
enabletime = self.checkbox_2.GetValue()
337+
338+
if enabletime==True:
341339
kwargs={}
342340
if details!="":
343341
kwargs['details']=details
@@ -359,8 +357,10 @@ def updatefunc(self, evt):
359357
if button_label2!="" and button_url2!="":
360358
secondbutton={'label':str(button_label2),'url':str(button_url2)}
361359
kwargs["buttons"].append(secondbutton)
360+
361+
start_time=time.time()
362362
kwargs['start']=int(start_time)
363-
elif rpcconnect==True:
363+
elif enabletime==False:
364364
kwargs={}
365365
if details!="":
366366
kwargs['details']=details
@@ -381,30 +381,28 @@ def updatefunc(self, evt):
381381
kwargs["buttons"].append(firstbutton)
382382
if button_label2!="" and button_url2!="":
383383
secondbutton={'label':str(button_label2),'url':str(button_url2)}
384-
kwargs["buttons"].append(secondbutton)
385-
kwargs['start']=int(start_time)
384+
kwargs["buttons"].append(secondbutton)
386385

387386
RPC = Presence(client_id=client_id)
388-
print('rpc closed')
389387
RPC.connect()
390388
print('rpc connected')
391-
rpcconnect=True
392389
try:
393390
config['Main']['client_id']=client_id
394391
config['Main']['state']=state
395392
config['Main']['details']=details
396-
config['Main']['large_image']=large_image
393+
config['Main']['large_image']=large_image_name
397394
config['Main']['large_text']=large_text
398-
config['Main']['small_image']=small_image
395+
config['Main']['small_image']=small_image_name
399396
config['Main']['small_text']=small_text
400397
config['Main']['button_label1']=button_label1
401398
config['Main']['button_url1']=button_url1
402399
config['Main']['button_label2']=button_label2
403400
config['Main']['button_url2']=button_url2
404401
with open("config.json","w") as new_config:
405402
json.dump(config,new_config)
403+
RPC.clear()
404+
print('rpc closed')
406405
RPC.update(**kwargs)
407-
rpcconnect=True
408406
except pypresence.exceptions.InvalidID:
409407
wx.MessageBox("Invalid Client ID", "Warning" ,wx.OK | wx.ICON_INFORMATION)
410408

@@ -464,5 +462,4 @@ def OnInit(self):
464462
# end of class appclass
465463
if __name__ == "__main__":
466464
app = appclass(0)
467-
app.MainLoop()
468-
465+
app.MainLoop()

0 commit comments

Comments
 (0)