-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsettings.py
1330 lines (1040 loc) · 78.2 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
#encoding=utf-8
# 'seleniumwire' and 'selenium 4' raise error when running python 2.x
# PS: python 2.x will be removed in future.
try:
# for Python2
from Tkinter import *
import ttk
import tkMessageBox as messagebox
except ImportError:
# for Python3
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
import os
import sys
import platform
import webbrowser
import base64
import time
import threading
import subprocess
import json
CONST_APP_VERSION = "Max inline Bot (2023.08.21)"
CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
CONST_MAXBOT_INT28_FILE = "MAXBOT_INT28_IDLE.txt"
CONST_HOMEPAGE_DEFAULT = "https://inline.app/zh/?language=zh-tw"
CONST_GENDER_DEFAULT = '小姐'
CONST_OCCASION_DEFAULT = '朋友聚餐'
URL_DONATE = 'https://max-everyday.com/about/#donate'
URL_HELP = 'https://max-everyday.com/2022/09/inline-bot/'
URL_RELEASE = 'https://github.com/max32002/inline_bot/releases'
URL_FB = 'https://www.facebook.com/maxbot.ticket'
CONST_WEBDRIVER_TYPE_SELENIUM = "selenium"
#CONST_WEBDRIVER_TYPE_STEALTH = "stealth"
CONST_WEBDRIVER_TYPE_UC = "undetected_chromedriver"
translate={}
def load_translate():
translate = {}
en_us={}
en_us["homepage"] = 'Homepage'
en_us["browser"] = 'Browser'
en_us["language"] = 'Language'
en_us["enable"] = 'Enable'
en_us["party_size"] = "Party size"
en_us["force_party_size"] = "Force Party size"
en_us["booking_time"] = "Time"
en_us["booking_time_alt"] = "Time (Alternative)"
en_us["user_info"] = "User Info"
en_us["user_name"] = "Name"
en_us["user_gender"] = "Gender"
en_us["user_tel"] = "Tel"
en_us["user_email"] = "Email"
en_us["booking_occasion"] = "Occasion"
en_us["booking_note"] = "Note"
en_us["credit_card_holder"] = "Credit Card Holder"
en_us["cardholder_name"] = "Name"
en_us["cardholder_email"] = "Email"
en_us["card_number"] = "Number"
en_us["card_exp"] = "Exp (MM/YY)"
en_us["card_ccv"] = "ccv"
en_us["auto_submit"] = "Auto submit"
en_us["verbose"] = 'Verbose mode'
en_us["running_status"] = 'Running Status'
en_us["running_url"] = 'Running URL'
en_us["status_idle"] = 'Idle'
en_us["status_paused"] = 'Paused'
en_us["status_enabled"] = 'Enabled'
en_us["status_running"] = 'Running'
en_us["idle"] = 'Idle'
en_us["resume"] = 'Resume'
en_us["preference"] = 'Preference'
en_us["advanced"] = 'Advanced'
en_us["runtime"] = 'Runtime'
en_us["about"] = 'About'
en_us["run"] = 'Run'
en_us["save"] = 'Save'
en_us["exit"] = 'Close'
en_us["copy"] = 'Copy'
en_us["restore_defaults"] = 'Restore Defaults'
en_us["done"] = 'Done'
en_us["maxbot_slogan"] = 'MaxinlineBot is a FREE and open source bot program. Wish you booking successfully.'
en_us["donate"] = 'Donate'
en_us["help"] = 'Help'
en_us["release"] = 'Release'
zh_tw={}
zh_tw["homepage"] = '售票網站'
zh_tw["browser"] = '瀏覽器'
zh_tw["language"] = '語言'
zh_tw["enable"] = '啟用'
zh_tw["party_size"] = "用餐人數"
zh_tw["force_party_size"] = "覆寫用餐人數"
zh_tw["booking_time"] = "用餐時段"
zh_tw["booking_time_alt"] = "用餐時段(備用)"
zh_tw["user_info"] = "聯絡資訊"
zh_tw["user_name"] = "訂位人姓名"
zh_tw["user_gender"] = "性別"
zh_tw["user_tel"] = "訂位人手機號碼"
zh_tw["user_email"] = "訂位人Email"
zh_tw["booking_occasion"] = "用餐目的"
zh_tw["booking_note"] = "其他備註"
zh_tw["credit_card_holder"] = "信用卡持有人"
zh_tw["cardholder_name"] = "持卡人姓名"
zh_tw["cardholder_email"] = "持卡人Email"
zh_tw["card_number"] = "卡號"
zh_tw["card_exp"] = "到期日 (MM/YY)"
zh_tw["card_ccv"] = "安全碼"
zh_tw["auto_submit"] = "自動「確認訂位」"
zh_tw["verbose"] = '輸出詳細除錯訊息'
zh_tw["running_status"] = '執行狀態'
zh_tw["running_url"] = '執行網址'
zh_tw["status_idle"] = '閒置中'
zh_tw["status_paused"] = '已暫停'
zh_tw["status_enabled"] = '已啟用'
zh_tw["status_running"] = '執行中'
zh_tw["idle"] = '暫停搶票'
zh_tw["resume"] = '接續搶票'
zh_tw["preference"] = '偏好設定'
zh_tw["advanced"] = '進階設定'
zh_tw["runtime"] = '執行階段'
zh_tw["about"] = '關於'
zh_tw["run"] = '搶票'
zh_tw["save"] = '存檔'
zh_tw["exit"] = '關閉'
zh_tw["copy"] = '複製'
zh_tw["restore_defaults"] = '恢復預設值'
zh_tw["done"] = '完成'
zh_tw["maxbot_slogan"] = 'MaxinlineBot 是一個免費、開放原始碼的搶票機器人。\n祝您預訂成功。'
zh_tw["donate"] = '打賞'
zh_tw["release"] = '所有可用版本'
zh_tw["help"] = '使用教學'
zh_cn={}
zh_cn["homepage"] = '售票网站'
zh_cn["browser"] = '浏览器'
zh_cn["language"] = '语言'
zh_cn["enable"] = '启用'
zh_cn["party_size"] = "用餐人数"
zh_cn["force_party_size"] = "覆写用餐人数"
zh_cn["booking_time"] = "用餐时段"
zh_cn["booking_time_alt"] = "用餐时段(备用)"
zh_cn["user_info"] = "联络资讯"
zh_cn["user_name"] = "订位人姓名"
zh_cn["user_gender"] = "性别"
zh_cn["user_tel"] = "订位人手机号码"
zh_cn["user_email"] = "订位人Email"
zh_cn["booking_occasion"] = "用餐目的"
zh_cn["booking_note"] = "其他備註"
zh_cn["credit_card_holder"] = "信用卡持有人"
zh_cn["cardholder_name"] = "持卡人姓名"
zh_cn["cardholder_email"] = "持卡人Email"
zh_cn["card_number"] = "卡号"
zh_cn["card_exp"] = "到期日 (MM/YY)"
zh_cn["card_ccv"] = "安全码"
zh_cn["auto_submit"] = "自动“确认订位”"
zh_cn["verbose"] = '输出详细除错讯息'
zh_cn["running_status"] = '执行状态'
zh_cn["running_url"] = '执行网址'
zh_cn["status_idle"] = '闲置中'
zh_cn["status_paused"] = '已暂停'
zh_cn["status_enabled"] = '已启用'
zh_cn["status_running"] = '执行中'
zh_cn["idle"] = '暂停抢票'
zh_cn["resume"] = '接续抢票'
zh_cn["preference"] = '偏好设定'
zh_cn["advanced"] = '进阶设定'
zh_cn["runtime"] = '运行'
zh_cn["about"] = '关于'
zh_cn["run"] = '抢票'
zh_cn["save"] = '存档'
zh_cn["exit"] = '关闭'
zh_cn["copy"] = '复制'
zh_cn["restore_defaults"] = '恢复默认值'
zh_cn["done"] = '完成'
zh_cn["maxbot_slogan"] = 'MaxinlineBot 是一个免费的开源机器人程序。\n祝您预订成功。'
zh_cn["donate"] = '打赏'
zh_cn["help"] = '使用教学'
zh_cn["release"] = '所有可用版本'
ja_jp={}
ja_jp["homepage"] = 'ホームページ'
ja_jp["browser"] = 'ブラウザ'
ja_jp["language"] = '言語'
ja_jp["enable"] = '有効'
ja_jp["party_size"] = "食事人数"
ja_jp["force_party_size"] = "人数を変更する"
ja_jp["booking_time"] = "食事時間"
ja_jp["booking_time_alt"] = "食事時間 (代替)"
ja_jp["user_info"] = "連絡先情報"
ja_jp["user_name"] = "予約者氏名"
ja_jp["user_gender"] = "性別"
ja_jp["user_tel"] = "携帯電話番号"
ja_jp["user_email"] = "メールアドレス"
ja_jp["booking_occasion"] = "ご利用目的"
ja_jp["booking_note"] = "その他ご希望"
ja_jp["credit_card_holder"] = "クレジット カード所有者"
ja_jp["cardholder_name"] = "所有者名"
ja_jp["cardholder_email"] = "所有者Email"
ja_jp["card_number"] = "番号"
ja_jp["card_exp"] = "Exp (MM/YY)"
ja_jp["card_ccv"] = "ccv"
ja_jp["auto_submit"] = "自動送信フォーム"
ja_jp["verbose"] = '詳細モード'
ja_jp["running_status"] = 'スターテス'
ja_jp["running_url"] = '現在の URL'
ja_jp["status_idle"] = '閒置中'
ja_jp["status_paused"] = '一時停止'
ja_jp["status_enabled"] = '有効'
ja_jp["status_running"] = 'ランニング'
ja_jp["idle"] = 'アイドル'
ja_jp["resume"] = '再開する'
ja_jp["preference"] = '設定'
ja_jp["advanced"] = '高度な設定'
ja_jp["runtime"] = 'ランタイム'
ja_jp["about"] = '情報'
ja_jp["run"] = 'チケットを取る'
ja_jp["save"] = '保存'
ja_jp["exit"] = '閉じる'
ja_jp["copy"] = 'コピー'
ja_jp["restore_defaults"] = 'デフォルトに戻す'
ja_jp["done"] = '終わり'
ja_jp["maxbot_slogan"] = 'MaxinlineBot は無料のオープン ソース ボット プログラムです。 予約が成功しますように。'
ja_jp["donate"] = '寄付'
ja_jp["help"] = '利用方法'
ja_jp["release"] = 'リリース'
translate['en_us']=en_us
translate['zh_tw']=zh_tw
translate['zh_cn']=zh_cn
translate['ja_jp']=ja_jp
return translate
def get_app_root():
# 讀取檔案裡的參數值
basis = ""
if hasattr(sys, 'frozen'):
basis = sys.executable
else:
basis = sys.argv[0]
app_root = os.path.dirname(basis)
return app_root
def get_default_config():
config_dict = {}
config_dict["homepage"] = CONST_HOMEPAGE_DEFAULT
config_dict["browser"] = "chrome"
config_dict["language"] = "English"
config_dict["adult_picker"] = "2"
config_dict["force_adult_picker"] = True
config_dict["book_now_time"] = ""
config_dict["book_now_time_alt"] = ""
config_dict["user_name"] = ""
config_dict["user_gender"] = CONST_GENDER_DEFAULT
config_dict["user_phone"] = ""
config_dict["user_email"] = ""
config_dict["booking_occasion"] = CONST_OCCASION_DEFAULT
config_dict["booking_note"] = ""
config_dict["cardholder_name"] = ""
config_dict["cardholder_email"] = ""
config_dict["cc_number"] = ""
config_dict["cc_exp"] = ""
config_dict["cc_ccv"] = ""
config_dict['cc_auto_submit'] = False
config_dict['advanced']={}
config_dict["advanced"]["adblock_plus_enable"] = False
config_dict["advanced"]["headless"] = False
config_dict["advanced"]["verbose"] = False
config_dict["webdriver_type"] = CONST_WEBDRIVER_TYPE_UC
return config_dict
def read_last_url_from_file():
ret = ""
if os.path.exists(CONST_MAXBOT_LAST_URL_FILE):
with open(CONST_MAXBOT_LAST_URL_FILE, "r") as text_file:
ret = text_file.readline()
return ret
def load_json():
app_root = get_app_root()
# overwrite config path.
config_filepath = os.path.join(app_root, CONST_MAXBOT_CONFIG_FILE)
config_dict = None
if os.path.isfile(config_filepath):
with open(config_filepath) as json_data:
config_dict = json.load(json_data)
else:
config_dict = get_default_config()
return config_filepath, config_dict
def btn_restore_defaults_clicked(language_code):
app_root = get_app_root()
config_filepath = os.path.join(app_root, CONST_MAXBOT_CONFIG_FILE)
config_dict = get_default_config()
import json
with open(config_filepath, 'w') as outfile:
json.dump(config_dict, outfile)
messagebox.showinfo(translate[language_code]["restore_defaults"], translate[language_code]["done"])
global root
load_GUI(root, config_dict)
def btn_idle_clicked(language_code):
app_root = get_app_root()
idle_filepath = os.path.join(app_root, CONST_MAXBOT_INT28_FILE)
with open(CONST_MAXBOT_INT28_FILE, "w") as text_file:
text_file.write("")
update_maxbot_runtime_status()
def btn_resume_clicked(language_code):
app_root = get_app_root()
idle_filepath = os.path.join(app_root, CONST_MAXBOT_INT28_FILE)
for i in range(10):
force_remove_file(idle_filepath)
update_maxbot_runtime_status()
def btn_save_clicked(language_code):
btn_save_act(language_code)
def format_time_string(data):
if not data is None:
data = data.replace(':',':')
return data
def btn_save_act(language_code, slience_mode=False):
app_root = get_app_root()
config_filepath = os.path.join(app_root, 'settings.json')
config_dict = get_default_config()
# read user input
global txt_homepage
global combo_browser
global combo_language
global txt_adult_picker
global txt_book_now_time
global txt_book_now_time_alt
global txt_user_name
global combo_user_gender
global txt_user_phone
global txt_user_email
global combo_booking_occasion
global txt_booking_note
global txt_cardholder_name
global txt_cardholder_email
global txt_card_number
global txt_card_exp
global txt_card_ccv
global chk_state_cc_auto_submit
global chk_state_force_adult_picker
global chk_state_verbose
global tabControl
is_all_data_correct = True
if is_all_data_correct:
#if combo_homepage.get().strip()=="":
if txt_homepage.get().strip()=="":
is_all_data_correct = False
messagebox.showerror("Error", "Please enter homepage")
else:
#config_dict["homepage"] = combo_homepage.get().strip()
config_dict["homepage"] = txt_homepage.get().strip()
if is_all_data_correct:
if combo_browser.get().strip()=="":
is_all_data_correct = False
messagebox.showerror("Error", "Please select a browser: chrome or firefox")
else:
config_dict["browser"] = combo_browser.get().strip()
if is_all_data_correct:
if combo_language.get().strip()=="":
is_all_data_correct = False
messagebox.showerror("Error", "Please select a language")
else:
config_dict["language"] = combo_language.get().strip()
# display as new language.
language_code = get_language_code_by_name(config_dict["language"])
if is_all_data_correct:
if txt_adult_picker.get().strip()=="":
is_all_data_correct = False
messagebox.showerror("Error", "Please enter party size")
else:
config_dict["adult_picker"] = txt_adult_picker.get().strip()
if is_all_data_correct:
if txt_book_now_time.get().strip()=="":
is_all_data_correct = False
tabControl.select(0)
txt_book_now_time.focus_set()
messagebox.showerror("Error", "Please enter booking time")
else:
config_dict["book_now_time"] = txt_book_now_time.get().strip()
config_dict["book_now_time"] = format_time_string(config_dict["book_now_time"])
if is_all_data_correct:
if txt_user_name.get().strip()=="":
is_all_data_correct = False
tabControl.select(0)
txt_user_name.focus_set()
messagebox.showerror("Error", "Please enter user name")
else:
config_dict["user_name"] = txt_user_name.get().strip()
if is_all_data_correct:
if txt_user_phone.get().strip()=="":
is_all_data_correct = False
tabControl.select(0)
txt_user_phone.focus_set()
messagebox.showerror("Error", "Please enter user phone")
else:
config_dict["user_phone"] = txt_user_phone.get().strip()
if is_all_data_correct:
if txt_user_email.get().strip()=="":
is_all_data_correct = False
tabControl.select(0)
txt_user_email.focus_set()
messagebox.showerror("Error", "Please enter user email")
else:
config_dict["user_email"] = txt_user_email.get().strip()
if is_all_data_correct:
config_dict["book_now_time_alt"] = txt_book_now_time_alt.get().strip()
config_dict["book_now_time_alt"] = format_time_string(config_dict["book_now_time_alt"])
config_dict["user_gender"] = combo_user_gender.get().strip()
config_dict["booking_occasion"] = combo_booking_occasion.get().strip()
config_dict["booking_note"] = txt_booking_note.get().strip()
config_dict["cardholder_name"] = txt_cardholder_name.get().strip()
config_dict["cardholder_email"] = txt_cardholder_email.get().strip()
config_dict["cc_number"] = txt_card_number.get().strip()
config_dict["cc_exp"] = txt_card_exp.get().strip()
config_dict["cc_ccv"] = txt_card_ccv.get().strip()
config_dict["cc_auto_submit"] = bool(chk_state_cc_auto_submit.get())
config_dict["force_adult_picker"] = bool(chk_state_force_adult_picker.get())
config_dict["advanced"]["verbose"] = bool(chk_state_verbose.get())
# save config.
if is_all_data_correct:
import json
with open(config_filepath, 'w') as outfile:
json.dump(config_dict, outfile)
if slience_mode==False:
messagebox.showinfo(translate[language_code]["save"], translate[language_code]["done"])
return is_all_data_correct
def btn_run_clicked(language_code):
print('run button pressed.')
Root_Dir = ""
save_ret = btn_save_act(language_code, slience_mode=True)
print("save config result:", save_ret)
if save_ret:
threading.Thread(target=launch_maxbot).start()
def launch_maxbot():
working_dir = os.path.dirname(os.path.realpath(__file__))
print("working_dir:", working_dir)
if hasattr(sys, 'frozen'):
print("execute in frozen mode")
# check platform here.
if platform.system() == 'Darwin':
print("execute MacOS python script")
subprocess.Popen("./inline_bot", shell=True, cwd=working_dir)
if platform.system() == 'Linux':
print("execute linux binary")
subprocess.Popen("./inline_bot", shell=True, cwd=working_dir)
if platform.system() == 'Windows':
print("execute .exe binary.")
subprocess.Popen("inline_bot.exe", shell=True, cwd=working_dir)
else:
interpreter_binary = 'python'
interpreter_binary_alt = 'python3'
if platform.system() == 'Darwin':
# try python3 before python.
interpreter_binary = 'python3'
interpreter_binary_alt = 'python'
print("execute in shell mode.")
#print("script path:", working_dir)
#messagebox.showinfo(title="Debug0", message=working_dir)
# some python3 binary, running in 'python' command.
try:
print('try', interpreter_binary)
s=subprocess.Popen([interpreter_binary, 'inline_bot.py'], cwd=working_dir)
#s=subprocess.Popen(['./chrome_tixcraft'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=working_dir)
#s=subprocess.run(['python3', 'chrome_tixcraft.py'], cwd=working_dir)
#messagebox.showinfo(title="Debug1", message=str(s))
except Exception as exc:
print('try', interpreter_binary_alt)
try:
s=subprocess.Popen([interpreter_binary_alt, 'inline_bot.py'], cwd=working_dir)
except Exception as exc:
msg=str(exc)
print("exeption:", msg)
#messagebox.showinfo(title="Debug2", message=msg)
pass
def open_url(url):
webbrowser.open_new(url)
def btn_exit_clicked():
root.destroy()
def callbackLanguageOnChange(event):
applyNewLanguage()
def get_language_code_by_name(new_language):
language_code = "en_us"
if u'繁體中文' in new_language:
language_code = 'zh_tw'
if u'簡体中文' in new_language:
language_code = 'zh_cn'
if u'日本語' in new_language:
language_code = 'ja_jp'
#print("new language code:", language_code)
return language_code
def applyNewLanguage():
global combo_language
new_language = combo_language.get().strip()
#print("new language value:", new_language)
language_code=get_language_code_by_name(new_language)
global lbl_homepage
global lbl_browser
global lbl_language
global lbl_adult_picker
global lbl_force_adult_picker
global lbl_book_now_time
global lbl_book_now_time_alt
global lbl_user_profile
global lbl_user_name
global lbl_user_gender
global lbl_user_phone
global lbl_user_email
global lbl_booking_occasion
global lbl_booking_note
global lbl_credit_card_holder
global lbl_cardholder_name
global lbl_cardholder_email
global lbl_card_number
global lbl_card_exp
global lbl_card_ccv
global lbl_cc_auto_submit
# for checkbox
global chk_cc_auto_submit
global chk_force_adult_picker
global tabControl
global lbl_slogan
global lbl_help
global lbl_donate
global lbl_release
global lbl_verbose
global chk_verbose
global lbl_maxbot_status
global lbl_maxbot_last_url
lbl_homepage.config(text=translate[language_code]["homepage"])
lbl_browser.config(text=translate[language_code]["browser"])
lbl_language.config(text=translate[language_code]["language"])
lbl_adult_picker.config(text=translate[language_code]["party_size"])
lbl_force_adult_picker.config(text=translate[language_code]["force_party_size"])
lbl_book_now_time.config(text=translate[language_code]["booking_time"])
lbl_book_now_time_alt.config(text=translate[language_code]["booking_time_alt"])
lbl_user_profile.config(text=translate[language_code]["user_info"])
lbl_user_name.config(text=translate[language_code]["user_name"])
lbl_user_gender.config(text=translate[language_code]["user_gender"])
lbl_user_phone.config(text=translate[language_code]["user_tel"])
lbl_user_email.config(text=translate[language_code]["user_email"])
lbl_booking_occasion.config(text=translate[language_code]["booking_occasion"])
lbl_booking_note.config(text=translate[language_code]["booking_note"])
lbl_credit_card_holder.config(text=translate[language_code]["credit_card_holder"])
lbl_cardholder_name.config(text=translate[language_code]["cardholder_name"])
lbl_cardholder_email.config(text=translate[language_code]["cardholder_email"])
lbl_card_number.config(text=translate[language_code]["card_number"])
lbl_card_exp.config(text=translate[language_code]["card_exp"])
lbl_card_ccv.config(text=translate[language_code]["card_ccv"])
lbl_cc_auto_submit.config(text=translate[language_code]["auto_submit"])
chk_cc_auto_submit.config(text=translate[language_code]["enable"])
chk_force_adult_picker.config(text=translate[language_code]["enable"])
tabControl.tab(0, text=translate[language_code]["preference"])
tabControl.tab(1, text=translate[language_code]["advanced"])
tabControl.tab(2, text=translate[language_code]["runtime"])
tabControl.tab(3, text=translate[language_code]["about"])
lbl_slogan.config(text=translate[language_code]["maxbot_slogan"])
lbl_help.config(text=translate[language_code]["help"])
lbl_donate.config(text=translate[language_code]["donate"])
lbl_release.config(text=translate[language_code]["release"])
lbl_verbose.config(text=translate[language_code]["verbose"])
chk_verbose.config(text=translate[language_code]["enable"])
lbl_maxbot_status.config(text=translate[language_code]["running_status"])
lbl_maxbot_last_url.config(text=translate[language_code]["running_url"])
global btn_run
global btn_save
global btn_exit
global btn_restore_defaults
global btn_idle
global btn_resume
btn_run.config(text=translate[language_code]["run"])
btn_save.config(text=translate[language_code]["save"])
btn_exit.config(text=translate[language_code]["exit"])
btn_restore_defaults.config(text=translate[language_code]["restore_defaults"])
btn_idle.config(text=translate[language_code]["idle"])
btn_resume.config(text=translate[language_code]["resume"])
def btn_exit_clicked():
root.destroy()
# PS: nothing need to do, at current process.
def callbackUserGenderOnChange(event):
showHideBlocks()
# PS: nothing need to do, at current process.
def callbackHomepageOnChange(event):
showHideBlocks()
def showHideBlocks(all_layout_visible=False):
pass
def PreferenctTab(root, config_dict, language_code, UI_PADDING_X):
homepage = None
language = "English"
homepage_list = (CONST_HOMEPAGE_DEFAULT)
gender_list = (CONST_GENDER_DEFAULT, '先生')
occasion_list = [
'慶生',
'約會',
'週年慶',
'家庭用餐',
'朋友聚餐',
'商務聚餐'
]
# output config:
print("config:", config_dict)
# output to GUI.
row_count = 0
frame_group_header = Frame(root)
group_row_count = 0
global lbl_homepage
lbl_homepage = Label(frame_group_header, text=translate[language_code]["homepage"])
lbl_homepage.grid(column=0, row=group_row_count, sticky = E)
'''
global combo_homepage
combo_homepage = ttk.Combobox(frame_group_header, state="readonly")
combo_homepage['values']= homepage_list
combo_homepage.set(homepage)
# PS: nothing need to do when on change event at this time.
combo_homepage.bind("<<ComboboxSelected>>", callbackHomepageOnChange)
combo_homepage.grid(column=1, row=group_row_count, sticky = W)
'''
global txt_homepage
txt_homepage_value = StringVar(frame_group_header, value=config_dict["homepage"])
txt_homepage = Entry(frame_group_header, width=30, textvariable = txt_homepage_value)
txt_homepage.grid(column=1, row=group_row_count, sticky = W)
group_row_count+=1
# party size
global lbl_adult_picker
lbl_adult_picker = Label(frame_group_header, text=translate[language_code]["party_size"])
lbl_adult_picker.grid(column=0, row=group_row_count, sticky = E)
global txt_adult_picker
txt_adult_picker_value = StringVar(frame_group_header, value=config_dict["adult_picker"])
txt_adult_picker = Entry(frame_group_header, width=30, textvariable = txt_adult_picker_value)
txt_adult_picker.grid(column=1, row=group_row_count, sticky = W)
group_row_count+=1
force_adult_picker = config_dict['force_adult_picker']
global lbl_force_adult_picker
lbl_force_adult_picker = Label(frame_group_header, text=translate[language_code]["force_party_size"])
lbl_force_adult_picker.grid(column=0, row=group_row_count, sticky = E)
global chk_state_force_adult_picker
chk_state_force_adult_picker = BooleanVar()
chk_state_force_adult_picker.set(force_adult_picker)
global chk_force_adult_picker
chk_force_adult_picker = Checkbutton(frame_group_header, text=translate[language_code]["enable"], variable=chk_state_force_adult_picker)
chk_force_adult_picker.grid(column=1, row=group_row_count, sticky = W)
group_row_count+=1
# Time
global lbl_book_now_time
lbl_book_now_time = Label(frame_group_header, text=translate[language_code]["booking_time"])
lbl_book_now_time.grid(column=0, row=group_row_count, sticky = E)
global txt_book_now_time
txt_book_now_time_value = StringVar(frame_group_header, value=config_dict["book_now_time"])
txt_book_now_time = Entry(frame_group_header, width=30, textvariable = txt_book_now_time_value)
txt_book_now_time.grid(column=1, row=group_row_count, sticky = W)
group_row_count+=1
# Time Alt
global lbl_book_now_time_alt
lbl_book_now_time_alt = Label(frame_group_header, text=translate[language_code]["booking_time_alt"])
lbl_book_now_time_alt.grid(column=0, row=group_row_count, sticky = E)
global txt_book_now_time_alt
txt_book_now_time_alt_value = StringVar(frame_group_header, value=config_dict["book_now_time_alt"])
txt_book_now_time_alt = Entry(frame_group_header, width=30, textvariable = txt_book_now_time_alt_value)
txt_book_now_time_alt.grid(column=1, row=group_row_count, sticky = W)
group_row_count+=1
# add first block to UI.
frame_group_header.grid(column=0, row=row_count, sticky = W, padx=UI_PADDING_X)
row_count+=1
'''
lbl_hr = Label(root, text="")
lbl_hr.grid(column=0, row=row_count)
row_count+=1
'''
# frame - user profile
frame_user_profile = Frame(root)
user_profile_row_count = 0
global lbl_user_profile
lbl_user_profile = Label(frame_user_profile, text=translate[language_code]["user_info"])
lbl_user_profile.grid(column=0, row=user_profile_row_count, columnspan=2, sticky = W, padx=UI_PADDING_X)
user_profile_row_count+=1
# User Name
global lbl_user_name
lbl_user_name = Label(frame_user_profile, text=translate[language_code]["user_name"])
lbl_user_name.grid(column=0, row=user_profile_row_count, sticky = E)
global txt_user_name
txt_user_name_value = StringVar(frame_user_profile, value=config_dict["user_name"])
txt_user_name = Entry(frame_user_profile, width=30, textvariable = txt_user_name_value)
txt_user_name.grid(column=1, row=user_profile_row_count, sticky = W)
user_profile_row_count+=1
# User Gender
global lbl_user_gender
lbl_user_gender = Label(frame_user_profile, text=translate[language_code]["user_gender"])
lbl_user_gender.grid(column=0, row=user_profile_row_count, sticky = E)
global combo_user_gender
combo_user_gender = ttk.Combobox(frame_user_profile, state="readonly")
combo_user_gender['values']= gender_list
combo_user_gender.set(config_dict["user_gender"])
# PS: nothing need to do when on change event at this time.
combo_user_gender.bind("<<ComboboxSelected>>", callbackUserGenderOnChange)
combo_user_gender.grid(column=1, row=user_profile_row_count, sticky = W)
user_profile_row_count+=1
# User Tel
global lbl_user_phone
lbl_user_phone = Label(frame_user_profile, text=translate[language_code]["user_tel"])
lbl_user_phone.grid(column=0, row=user_profile_row_count, sticky = E)
global txt_user_phone
txt_user_phone_value = StringVar(frame_user_profile, value=config_dict["user_phone"])
txt_user_phone = Entry(frame_user_profile, width=30, textvariable = txt_user_phone_value)
txt_user_phone.grid(column=1, row=user_profile_row_count, sticky = W)
user_profile_row_count+=1
# User Email
global lbl_user_email
lbl_user_email = Label(frame_user_profile, text=translate[language_code]["user_email"])
lbl_user_email.grid(column=0, row=user_profile_row_count, sticky = E)
global txt_user_email
txt_user_email_value = StringVar(frame_user_profile, value=config_dict["user_email"])
txt_user_email = Entry(frame_user_profile, width=30, textvariable = txt_user_email_value)
txt_user_email.grid(column=1, row=user_profile_row_count, sticky = W)
user_profile_row_count+=1
# User Gender
global lbl_booking_occasion
lbl_booking_occasion = Label(frame_user_profile, text=translate[language_code]["booking_occasion"])
lbl_booking_occasion.grid(column=0, row=user_profile_row_count, sticky = E)
global combo_booking_occasion
combo_booking_occasion = ttk.Combobox(frame_user_profile, state="readonly")
combo_booking_occasion['values']= occasion_list
combo_booking_occasion.set(config_dict["booking_occasion"])
# PS: nothing need to do when on change event at this time.
combo_booking_occasion.grid(column=1, row=user_profile_row_count, sticky = W)
user_profile_row_count+=1
# User Email
global lbl_booking_note
lbl_booking_note = Label(frame_user_profile, text=translate[language_code]["booking_note"])
lbl_booking_note.grid(column=0, row=user_profile_row_count, sticky = E)
global txt_booking_note
txt_booking_note_value = StringVar(frame_user_profile, value=config_dict["booking_note"])
txt_booking_note = Entry(frame_user_profile, width=30, textvariable = txt_booking_note_value)
txt_booking_note.grid(column=1, row=user_profile_row_count, sticky = W)
# add second block to UI.
frame_user_profile.grid(column=0, row=row_count, sticky = W, padx=UI_PADDING_X)
row_count+=1
'''
lbl_hr = Label(root, text="")
lbl_hr.grid(column=0, row=row_count)
row_count+=1
'''
# frame - credit card
frame_cc = Frame(root)
cc_row_count = 0
global lbl_credit_card_holder
lbl_credit_card_holder = Label(frame_cc, text=translate[language_code]["credit_card_holder"])
lbl_credit_card_holder.grid(column=0, row=cc_row_count, columnspan=2, sticky = W, padx=UI_PADDING_X)
cc_row_count+=1
global lbl_cardholder_name
lbl_cardholder_name = Label(frame_cc, text=translate[language_code]["cardholder_name"])
lbl_cardholder_name.grid(column=0, row=cc_row_count, sticky = E)
global txt_cardholder_name
global txt_cardholder_name_value
txt_cardholder_name_value = StringVar(frame_cc, value=config_dict["cardholder_name"])
txt_cardholder_name = Entry(frame_cc, width=30, textvariable = txt_cardholder_name_value)
txt_cardholder_name.grid(column=1, row=cc_row_count, sticky = W)
cc_row_count+=1
global lbl_cardholder_email
lbl_cardholder_email = Label(frame_cc, text="Email")
lbl_cardholder_email.grid(column=0, row=cc_row_count, sticky = E)
global txt_cardholder_email
txt_cardholder_email_value = StringVar(frame_cc, value=config_dict["cardholder_email"])
txt_cardholder_email = Entry(frame_cc, width=30, textvariable = txt_cardholder_email_value)
txt_cardholder_email.grid(column=1, row=cc_row_count, sticky = W)
cc_row_count+=1
global lbl_card_number
lbl_card_number = Label(frame_cc, text=translate[language_code]["card_number"])
lbl_card_number.grid(column=0, row=cc_row_count, sticky = E)
global txt_card_number
txt_card_number_value = StringVar(frame_cc, value=config_dict["cc_number"])
txt_card_number = Entry(frame_cc, width=30, textvariable = txt_card_number_value)
txt_card_number.grid(column=1, row=cc_row_count, sticky = W)
cc_row_count+=1
global lbl_card_exp
lbl_card_exp = Label(frame_cc, text=translate[language_code]["card_exp"])
lbl_card_exp.grid(column=0, row=cc_row_count, sticky = E)
global txt_card_exp
txt_card_exp_value = StringVar(frame_cc, value=config_dict["cc_exp"])
txt_card_exp = Entry(frame_cc, width=30, textvariable = txt_card_exp_value)
txt_card_exp.grid(column=1, row=cc_row_count, sticky = W)
cc_row_count+=1
global lbl_card_ccv
lbl_card_ccv = Label(frame_cc, text=translate[language_code]["card_ccv"])
lbl_card_ccv.grid(column=0, row=cc_row_count, sticky = E)
global txt_card_ccv
global txt_card_ccv_value
txt_card_ccv_value = StringVar(frame_cc, value=config_dict["cc_ccv"])
txt_card_ccv = Entry(frame_cc, width=30, textvariable = txt_card_ccv_value)
txt_card_ccv.grid(column=1, row=cc_row_count, sticky = W)
cc_row_count+=1
cc_auto_submit = config_dict['cc_auto_submit']
global lbl_cc_auto_submit
lbl_cc_auto_submit = Label(frame_cc, text=translate[language_code]["auto_submit"])
lbl_cc_auto_submit.grid(column=0, row=cc_row_count, sticky = E)
global chk_state_cc_auto_submit
chk_state_cc_auto_submit = BooleanVar()
chk_state_cc_auto_submit.set(cc_auto_submit)
global chk_cc_auto_submit
chk_cc_auto_submit = Checkbutton(frame_cc, text=translate[language_code]["enable"], variable=chk_state_cc_auto_submit)
chk_cc_auto_submit.grid(column=1, row=cc_row_count, sticky = W)
cc_row_count+=1
# add third block to UI.
frame_cc.grid(column=0, row=row_count, sticky = W, padx=UI_PADDING_X)
def AdvancedTab(root, config_dict, language_code, UI_PADDING_X):
row_count = 0
frame_group_header = Frame(root)