-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
577 lines (462 loc) · 23.8 KB
/
main.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
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
#
# generated by wxGlade 1.0.1 on Wed Mar 31 23:50:32 2021
"""
___ ___ ___ ___
/\ \ /\ \ |\__\ /\ \
/::\ \ /::\ \ |:| | /::\ \
/:/\:\ \ /:/\:\ \ |:| | /:/\:\ \
/::\~\:\ \ /::\~\:\ \ |:|__|__ /::\~\:\ \
/:/\:\ \:\__\ /:/\:\ \:\__\ /::::\__\ /:/\:\ \:\__\
\/_|::\/:/ / \/__\:\/:/ / /:/~~/~ \/_|::\/:/ /
|:|::/ / \::/ / /:/ / |:|::/ /
|:|\/__/ /:/ / \/__/ |:|\/__/
|:| | /:/ / |:| |
\|__| \/__/ \|__|
"""
import wx
from wx.adv import TaskBarIcon as TaskBarIcon
import os
import sys
from wx.core import Icon
import pypresence
from pypresence import Presence
import time
########### JSON
import json
conf=open('config.json')
config=json.load(conf)
client_id=config['Main']['client_id']
state=config['Main']['state']
details=config['Main']['details']
large_image=config['Main']['large_image']
large_text=config['Main']['large_text']
small_image=config['Main']['small_image']
small_text=config['Main']['small_text']
button_label1=config['Main']['button_label1']
button_url1=config['Main']['button_url1']
button_label2=config['Main']['button_label2']
button_url2=config['Main']['button_url2']
enable_time=config['Main']['enable_time']
#####################
cd = dir_path = os.path.dirname(os.path.realpath(__file__))
# begin wxGlade: dependencies
# end wxGlade
# begin wxGlade: extracode
# end wxGlade
################################################################################
# PLEASE DON'T REMOVE THESE. IF YOU DO, PLEASE GIVE CREDIT WHEN ASKED ABOUT THE PROGRAM, THANK YOU!!
client_id_App = "827873727396053002"
RPC = Presence(client_id=client_id_App)
RPC.connect()
RPC.update(state="Checkout the Github!", large_image="logo",large_text="Discord Custom RPC", buttons=[{"label": "Github", "url": "https://github.com/Rayrsn/Discord-Custom-RPC"}])
################################################################################
class MainTaskBarIcon(TaskBarIcon):
TBMENU_RESTORE = wx.NewIdRef()
TBMENU_CLOSE = wx.NewIdRef()
TBMENU_CHANGE = wx.NewIdRef()
TBMENU_REMOVE = wx.NewIdRef()
def __init__(self, frame):
TaskBarIcon.__init__(self, wx.adv.TBI_DOCK)
self.frame = frame
# Set the image
img = wx.Image("icon.ico", wx.BITMAP_TYPE_ANY)
bmp = wx.Bitmap(img)
self.icon = Icon(bmp)
self.icon.CopyFromBitmap(bmp)
self.SetIcon(self.icon, "Discord Custom RPC")
self.imgidx = 1
# bind some events
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DCLICK, self.OnTaskBarActivate)
self.Bind(wx.EVT_MENU, self.OnTaskBarActivate, id=self.TBMENU_RESTORE)
self.Bind(wx.EVT_MENU, self.OnTaskBarClose, id=self.TBMENU_CLOSE)
self.Bind(wx.EVT_MENU, self.OnTaskBarChange, id=self.TBMENU_CHANGE)
self.Bind(wx.EVT_MENU, self.OnTaskBarRemove, id=self.TBMENU_REMOVE)
def CreatePopupMenu(self):
menu = wx.Menu()
menu.Append(self.TBMENU_RESTORE, "Restore Custom RPC")
menu.Append(self.TBMENU_CLOSE, "Close Custom RPC")
return menu
def MakeIcon(self, img):
if "wxMSW" in wx.PlatformInfo:
img = img.Scale(16, 16)
elif "wxGTK" in wx.PlatformInfo:
img = img.Scale(22, 22)
icon = wx.Icon(img.ConvertToBitmap())
return icon
def OnTaskBarActivate(self, evt):
if self.frame.IsIconized():
self.frame.Iconize(False)
if not self.frame.IsShown():
self.frame.Show(True)
self.frame.Raise()
def OnTaskBarClose(self, evt):
wx.CallAfter(self.frame.Close)
def OnTaskBarChange(self, evt):
names = [ "default" ]
name = names[self.imgidx]
eImg = getattr(self.icon, name)
self.imgidx += 1
if self.imgidx >= len(names):
self.imgidx = 0
icon = self.MakeIcon(eImg.Image)
self.SetIcon(icon, "This is a new icon: " + name)
def OnTaskBarRemove(self, evt):
self.RemoveIcon()
class frameclass(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: frameclass.__init__
kwds["style"] = kwds.get("style", 0) | wx.CAPTION | wx.CLIP_CHILDREN | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.SYSTEM_MENU
wx.Frame.__init__(self, *args, **kwds)
self.SetSize((470, 620))
self.SetTitle("Custom RPC")
_icon = wx.NullIcon
_icon.CopyFromBitmap(wx.Bitmap("./icon.ico", wx.BITMAP_TYPE_ANY))
self.SetIcon(_icon)
self.SetBackgroundColour(wx.Colour(34, 35, 42))
self.panel_1 = wx.Panel(self, wx.ID_ANY)
grid_sizer_1 = wx.GridSizer(16, 2, 0, 0)
label_1 = wx.StaticText(self.panel_1, wx.ID_ANY, "Client ID: *")
label_1.SetMinSize((200, 20))
label_1.SetForegroundColour(wx.Colour(221, 220, 213))
label_1.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_ITALIC, wx.FONTWEIGHT_BOLD, 0, "Arial"))
grid_sizer_1.Add(label_1, 0, wx.ALIGN_CENTER, 0)
grid_sizer_1.Add((0, 0), 0, 0, 0)
self.text_ctrl_1 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
self.text_ctrl_1.SetMinSize((190, 25))
self.text_ctrl_1.SetBackgroundColour(wx.Colour(183, 182, 182))
grid_sizer_1.Add(self.text_ctrl_1, 0, wx.LEFT, 13)
label_12 = wx.StaticText(self.panel_1, wx.ID_ANY, "Button 1:")
label_12.SetMinSize((200, 20))
label_12.SetForegroundColour(wx.Colour(221, 220, 213))
label_12.SetFont(wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
grid_sizer_1.Add(label_12, 0, wx.ALIGN_CENTER | wx.RIGHT, 50)
label_2 = wx.StaticText(self.panel_1, wx.ID_ANY, "Details:")
label_2.SetMinSize((200, 20))
label_2.SetForegroundColour(wx.Colour(221, 220, 213))
label_2.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, 0, ""))
grid_sizer_1.Add(label_2, 0, wx.ALIGN_CENTER, 0)
label_8 = wx.StaticText(self.panel_1, wx.ID_ANY, "Label:")
label_8.SetMinSize((200, 20))
label_8.SetForegroundColour(wx.Colour(221, 220, 213))
label_8.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, 0, ""))
grid_sizer_1.Add(label_8, 0, wx.ALIGN_CENTER, 0)
self.text_ctrl_2 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
self.text_ctrl_2.SetMinSize((190, 25))
self.text_ctrl_2.SetBackgroundColour(wx.Colour(183, 182, 182))
grid_sizer_1.Add(self.text_ctrl_2, 0, wx.LEFT, 13)
self.text_ctrl_11 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
self.text_ctrl_11.SetMinSize((190, 25))
self.text_ctrl_11.SetBackgroundColour(wx.Colour(183, 182, 182))
grid_sizer_1.Add(self.text_ctrl_11, 0, wx.LEFT, 13)
label_3 = wx.StaticText(self.panel_1, wx.ID_ANY, "State:")
label_3.SetMinSize((200, 20))
label_3.SetForegroundColour(wx.Colour(221, 220, 213))
label_3.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, 0, ""))
grid_sizer_1.Add(label_3, 0, wx.ALIGN_CENTER, 0)
label_9 = wx.StaticText(self.panel_1, wx.ID_ANY, "URL:")
label_9.SetMinSize((200, 20))
label_9.SetForegroundColour(wx.Colour(221, 220, 213))
label_9.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, 0, ""))
grid_sizer_1.Add(label_9, 0, wx.ALIGN_CENTER, 0)
self.text_ctrl_3 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
self.text_ctrl_3.SetMinSize((190, 25))
self.text_ctrl_3.SetBackgroundColour(wx.Colour(183, 182, 182))
grid_sizer_1.Add(self.text_ctrl_3, 0, wx.LEFT, 13)
self.text_ctrl_10 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
self.text_ctrl_10.SetMinSize((190, 25))
self.text_ctrl_10.SetBackgroundColour(wx.Colour(183, 182, 182))
grid_sizer_1.Add(self.text_ctrl_10, 0, wx.LEFT, 13)
label_4 = wx.StaticText(self.panel_1, wx.ID_ANY, "Large Image Name:")
label_4.SetMinSize((200, 20))
label_4.SetForegroundColour(wx.Colour(221, 220, 213))
label_4.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, 0, ""))
grid_sizer_1.Add(label_4, 0, wx.ALIGN_CENTER, 0)
grid_sizer_1.Add((0, 0), 0, 0, 0)
self.text_ctrl_4 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
self.text_ctrl_4.SetMinSize((190, 25))
self.text_ctrl_4.SetBackgroundColour(wx.Colour(183, 182, 182))
grid_sizer_1.Add(self.text_ctrl_4, 0, wx.LEFT, 13)
label_13 = wx.StaticText(self.panel_1, wx.ID_ANY, "Button 2:")
label_13.SetMinSize((200, 20))
label_13.SetForegroundColour(wx.Colour(221, 220, 213))
label_13.SetFont(wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
grid_sizer_1.Add(label_13, 0, wx.ALIGN_CENTER | wx.RIGHT, 50)
label_5 = wx.StaticText(self.panel_1, wx.ID_ANY, "Large Image Text:")
label_5.SetMinSize((200, 20))
label_5.SetForegroundColour(wx.Colour(221, 220, 213))
label_5.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, 0, ""))
grid_sizer_1.Add(label_5, 0, wx.ALIGN_CENTER, 0)
label_10 = wx.StaticText(self.panel_1, wx.ID_ANY, "Label:")
label_10.SetMinSize((200, 20))
label_10.SetForegroundColour(wx.Colour(221, 220, 213))
label_10.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, 0, ""))
grid_sizer_1.Add(label_10, 0, wx.ALIGN_CENTER, 0)
self.text_ctrl_5 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
self.text_ctrl_5.SetMinSize((190, 25))
self.text_ctrl_5.SetBackgroundColour(wx.Colour(183, 182, 182))
grid_sizer_1.Add(self.text_ctrl_5, 0, wx.LEFT, 13)
self.text_ctrl_9 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
self.text_ctrl_9.SetMinSize((190, 25))
self.text_ctrl_9.SetBackgroundColour(wx.Colour(183, 182, 182))
grid_sizer_1.Add(self.text_ctrl_9, 0, wx.LEFT, 13)
label_6 = wx.StaticText(self.panel_1, wx.ID_ANY, "Small Image Name:")
label_6.SetMinSize((200, 20))
label_6.SetForegroundColour(wx.Colour(221, 220, 213))
label_6.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, 0, ""))
grid_sizer_1.Add(label_6, 0, wx.ALIGN_CENTER, 0)
label_11 = wx.StaticText(self.panel_1, wx.ID_ANY, "URL:")
label_11.SetMinSize((200, 20))
label_11.SetForegroundColour(wx.Colour(221, 220, 213))
label_11.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, 0, ""))
grid_sizer_1.Add(label_11, 0, wx.ALIGN_CENTER, 0)
self.text_ctrl_6 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
self.text_ctrl_6.SetMinSize((190, 25))
self.text_ctrl_6.SetBackgroundColour(wx.Colour(183, 182, 182))
grid_sizer_1.Add(self.text_ctrl_6, 0, wx.LEFT, 13)
self.text_ctrl_8 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
self.text_ctrl_8.SetMinSize((190, 25))
self.text_ctrl_8.SetBackgroundColour(wx.Colour(183, 182, 182))
grid_sizer_1.Add(self.text_ctrl_8, 0, wx.LEFT, 13)
label_7 = wx.StaticText(self.panel_1, wx.ID_ANY, "Small Image Text:")
label_7.SetMinSize((200, 20))
label_7.SetForegroundColour(wx.Colour(221, 220, 213))
label_7.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, 0, ""))
grid_sizer_1.Add(label_7, 0, wx.ALIGN_CENTER, 0)
grid_sizer_1.Add((0, 0), 0, 0, 0)
self.text_ctrl_12 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "")
self.text_ctrl_12.SetMinSize((190, 25))
self.text_ctrl_12.SetBackgroundColour(wx.Colour(183, 182, 182))
grid_sizer_1.Add(self.text_ctrl_12, 0, wx.LEFT, 13)
self.checkbox_2 = wx.CheckBox(self.panel_1, wx.ID_ANY, "Enable Time ", style=wx.ALIGN_RIGHT)
self.checkbox_2.SetForegroundColour(wx.Colour(221, 220, 213))
self.checkbox_2.SetFont(wx.Font(14, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
grid_sizer_1.Add(self.checkbox_2, 0, wx.EXPAND | wx.RESERVE_SPACE_EVEN_IF_HIDDEN | wx.RIGHT, 35)
static_line_1 = wx.StaticLine(self.panel_1, wx.ID_ANY)
static_line_1.SetMinSize((227, 2))
static_line_1.SetForegroundColour(wx.Colour(255, 0, 0))
grid_sizer_1.Add(static_line_1, 0, wx.TOP, 16)
static_line_2 = wx.StaticLine(self.panel_1, wx.ID_ANY)
static_line_2.SetMinSize((227, 2))
static_line_2.SetForegroundColour(wx.Colour(255, 0, 0))
grid_sizer_1.Add(static_line_2, 0, wx.TOP, 16)
self.button_1 = wx.Button(self.panel_1, wx.ID_ANY, "", style=wx.BORDER_NONE)
self.button_1.SetMinSize((220, 30))
self.button_1.SetBackgroundColour(wx.Colour(34, 35, 42))
self.button_1.SetForegroundColour(wx.Colour(34, 35, 42))
self.button_1.SetBitmap(wx.Bitmap(cd + "/" + "update.bmp", wx.BITMAP_TYPE_ANY), dir=wx.TOP)
self.button_1.SetBitmapPressed(wx.Bitmap(cd + "/" + "update_pressed.bmp", wx.BITMAP_TYPE_ANY))
grid_sizer_1.Add(self.button_1, 0, wx.BOTTOM, 0)
self.button_2 = wx.Button(self.panel_1, wx.ID_ANY, "", style=wx.BORDER_NONE)
self.button_2.SetMinSize((220, 30))
self.button_2.SetBackgroundColour(wx.Colour(34, 35, 42))
self.button_2.SetForegroundColour(wx.Colour(34, 35, 42))
self.button_2.SetBitmap(wx.Bitmap(cd + "/" + "disconnect.bmp", wx.BITMAP_TYPE_ANY), dir=wx.TOP)
self.button_2.SetBitmapPressed(wx.Bitmap(cd + "/" + "disconnect_pressed.bmp", wx.BITMAP_TYPE_ANY))
grid_sizer_1.Add(self.button_2, 0, wx.BOTTOM, 0)
self.panel_1.SetSizer(grid_sizer_1)
self.Layout()
# end wxGlade
self.Bind(wx.EVT_BUTTON, self.updatefunc, self.button_1)
self.Bind(wx.EVT_BUTTON, self.dcfunc, self.button_2)
self.Bind(wx.EVT_TEXT, self.get_textbox_client_id, self.text_ctrl_1)
self.Bind(wx.EVT_TEXT, self.get_textbox_details, self.text_ctrl_2)
self.Bind(wx.EVT_TEXT, self.get_textbox_state, self.text_ctrl_3)
self.Bind(wx.EVT_TEXT, self.get_textbox_large_img_name, self.text_ctrl_4)
self.Bind(wx.EVT_TEXT, self.get_textbox_large_img_text, self.text_ctrl_5)
self.Bind(wx.EVT_TEXT, self.get_textbox_small_img_name, self.text_ctrl_6)
self.Bind(wx.EVT_TEXT, self.get_textbox_small_img_text, self.text_ctrl_12)
self.Bind(wx.EVT_TEXT, self.get_textbox_label_btn1, self.text_ctrl_11)
self.Bind(wx.EVT_TEXT, self.get_textbox_url_btn1, self.text_ctrl_10)
self.Bind(wx.EVT_TEXT, self.get_textbox_label_btn2, self.text_ctrl_9)
self.Bind(wx.EVT_TEXT, self.get_textbox_url_btn2, self.text_ctrl_8)
self.Bind(wx.EVT_ICONIZE, self.onMinimize)
self.Bind(wx.EVT_CLOSE, self.onClose)
#self.Bind(wx.EVT_BUTTON, self.Onmsgbox)
self.text_ctrl_1.ChangeValue(client_id)
self.text_ctrl_2.ChangeValue(details)
self.text_ctrl_3.ChangeValue(state)
self.text_ctrl_4.ChangeValue(large_image)
self.text_ctrl_5.ChangeValue(large_text)
self.text_ctrl_6.ChangeValue(small_image)
self.text_ctrl_12.ChangeValue(small_text)
self.text_ctrl_11.ChangeValue(button_label1)
self.text_ctrl_10.ChangeValue(button_url1)
self.text_ctrl_9.ChangeValue(button_label2)
self.text_ctrl_8.ChangeValue(button_url2)
if enable_time == "True":
self.checkbox_2.SetValue(True)
elif enable_time == "False":
self.checkbox_2.SetValue(False)
self.tbicon = MainTaskBarIcon(self)
###############################################################################
def get_textbox_client_id(self, evt):
client_id_ent = (str(self.text_ctrl_1.GetValue()))
def get_textbox_details(self, evt):
global details
details = (str(self.text_ctrl_2.GetValue()))
def get_textbox_state(self, evt):
global state
state = (str(self.text_ctrl_3.GetValue()))
def get_textbox_large_img_name(self, evt):
global large_image_name
large_image_name = (str(self.text_ctrl_4.GetValue()))
def get_textbox_large_img_text(self, evt):
global large_text
large_text = (str(self.text_ctrl_5.GetValue()))
def get_textbox_small_img_name(self, evt):
global small_image_name
small_image_name = (str(self.text_ctrl_6.GetValue()))
def get_textbox_small_img_text(self, evt):
global small_text
small_text = (str(self.text_ctrl_12.GetValue()))
def get_textbox_label_btn1(self, evt):
global button_label1
button_label1 = (str(self.text_ctrl_11.GetValue()))
def get_textbox_url_btn1(self, evt):
global button_url1
button_url1 = (str(self.text_ctrl_10.GetValue()))
def get_textbox_label_btn2(self, evt):
global button_label2
button_label2 = (str(self.text_ctrl_9.GetValue()))
def get_textbox_url_btn2(self, evt):
global button_url2
button_url2 = (str(self.text_ctrl_8.GetValue()))
def get_textbox_url_btn2(self, evt):
global enable_time_checkbox
enable_time_checkbox = (str(self.checkbox_2.GetValue()))
def updatefunc(self, evt):
global RPC
RPC.clear()
client_id_ent = (str(self.text_ctrl_1.GetValue()))
details = (str(self.text_ctrl_2.GetValue()))
state = (str(self.text_ctrl_3.GetValue()))
large_image_name = (str(self.text_ctrl_4.GetValue()))
large_text = (str(self.text_ctrl_5.GetValue()))
small_image_name = (str(self.text_ctrl_6.GetValue()))
small_text = (str(self.text_ctrl_12.GetValue()))
button_label1 = (str(self.text_ctrl_11.GetValue()))
button_url1 = (str(self.text_ctrl_10.GetValue()))
button_label2 = (str(self.text_ctrl_9.GetValue()))
button_url2 = (str(self.text_ctrl_8.GetValue()))
enable_time_checkbox = (str(self.checkbox_2.GetValue()))
client_id = client_id_ent
print(client_id)
enabletime = self.checkbox_2.GetValue()
if enabletime==True:
kwargs={}
if details!="":
kwargs['details']=details
if state!="":
kwargs['state']=state
if large_image_name!="":
kwargs['large_image']=large_image_name
if large_text!="":
kwargs['large_text']=large_text
if small_image_name!="":
kwargs['small_image']=small_image_name
if small_text!="":
kwargs['small_text']=small_text
if button_label1!="" or button_label2!="":
kwargs['buttons']=[]
if button_label1!="" and button_url1!="":
firstbutton={'label':str(button_label1),'url':str(button_url1)}
kwargs["buttons"].append(firstbutton)
if button_label2!="" and button_url2!="":
secondbutton={'label':str(button_label2),'url':str(button_url2)}
kwargs["buttons"].append(secondbutton)
start_time=time.time()
kwargs['start']=int(start_time)
elif enabletime==False:
kwargs={}
if details!="":
kwargs['details']=details
if state!="":
kwargs['state']=state
if large_image_name!="":
kwargs['large_image']=large_image_name
if large_text!="":
kwargs['large_text']=large_text
if small_image_name!="":
kwargs['small_image']=small_image_name
if small_text!="":
kwargs['small_text']=small_text
if button_label1!="" or button_label2!="":
kwargs['buttons']=[]
if button_label1!="" and button_url1!="":
firstbutton={'label':str(button_label1),'url':str(button_url1)}
kwargs["buttons"].append(firstbutton)
if button_label2!="" and button_url2!="":
secondbutton={'label':str(button_label2),'url':str(button_url2)}
kwargs["buttons"].append(secondbutton)
RPC = Presence(client_id=client_id)
RPC.connect()
print('rpc connected')
try:
config['Main']['client_id']=client_id
config['Main']['state']=state
config['Main']['details']=details
config['Main']['large_image']=large_image_name
config['Main']['large_text']=large_text
config['Main']['small_image']=small_image_name
config['Main']['small_text']=small_text
config['Main']['button_label1']=button_label1
config['Main']['button_url1']=button_url1
config['Main']['button_label2']=button_label2
config['Main']['button_url2']=button_url2
config['Main']['enable_time']=enable_time_checkbox
with open("config.json","w") as new_config:
json.dump(config,new_config)
RPC.clear()
print('rpc cleared')
RPC.update(**kwargs)
except pypresence.exceptions.InvalidID:
wx.MessageBox("Invalid Client ID", "Warning" ,wx.OK | wx.ICON_INFORMATION)
def dcfunc(self, evt):
RPC.clear()
print('disconnected')
def onClose(self, evt):
# if self.tbicon is not None:
# self.tbIcon.RemoveIcon()
# self.tbicon.Destroy()
self.Destroy()
sys.exit()
#----------------------------------------------------------------------
def onMinimize(self, event):
if self.IsIconized():
self.Hide()
# end of class frameclass
class popup(wx.Dialog):
def __init__(self, *args, **kwds):
# begin wxGlade: popup.__init__
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_DIALOG_STYLE
wx.Dialog.__init__(self, *args, **kwds)
self.SetTitle("Invalid Client ID")
sizer_1 = wx.BoxSizer(wx.VERTICAL)
grid_sizer_1 = wx.GridSizer(3, 1, 0, 0)
sizer_1.Add(grid_sizer_1, 1, wx.EXPAND, 0)
grid_sizer_1.Add((240, 20), 0, 0, 0)
label_1 = wx.StaticText(self, wx.ID_ANY, "Invalid Client ID")
grid_sizer_1.Add(label_1, 0, wx.ALIGN_CENTER, 0)
grid_sizer_1.Add((240, 20), 0, 0, 0)
sizer_2 = wx.StdDialogButtonSizer()
sizer_1.Add(sizer_2, 0, wx.ALIGN_RIGHT | wx.ALL, 4)
self.button_OK = wx.Button(self, wx.ID_OK, "")
self.button_OK.SetDefault()
sizer_2.AddButton(self.button_OK)
sizer_2.Realize()
self.SetSizer(sizer_1)
sizer_1.Fit(self)
self.SetAffirmativeId(self.button_OK.GetId())
self.Layout()
class appclass(wx.App):
def OnInit(self):
self.frame = frameclass(None, wx.ID_ANY, "")
self.SetTopWindow(self.frame)
self.frame.Show()
return True
# end of class appclass
if __name__ == "__main__":
app = appclass(0)
app.MainLoop()