-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEqSearch.py
857 lines (771 loc) · 31.4 KB
/
EqSearch.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
import re
from tkinter import *
import webbrowser
#create dictionary from database file
result = []
with open("Equip_DB.txt", "r", encoding='utf-8') as infile:
for line in infile:
if line.startswith("Object"): #Check if line starts with 'Object'
result.append([line, []]) #Create new list with format --> [key, [list of corresponding text]]
else:
result[-1][1].append(line) #Append text to previously found key.
eqDict ={k: "".join(v) for k, v in result} #Form required dictionary.
#define class list
classList = ["none","Augurer","Barbarian","Bladesinger","Cleric","Druid","Fathomer","Mage","Nephandi","Paladin","Ranger","Thief","Vampire","Warrior"]
# define race list
raceList = ["none", "Human", "Dwarf", "Elf", "Halfling", "Pixie", "Half-Elf", "Half-Ogre", "Half-Troll", "Half-Orc", "Gith", "Sea-Elf", "Drow", "Lizardman", "Gnome", "Dragonborn", "Tiefling"]
#define wearlocs list
wearList = ["none","wield","light","finger","neck","head","legs","feet","hands","arms","eyes","ears","body","about","shield","hold","wrist","waist","face","ankle","back"]
#define align list
alignList = ["none","evil","neut","good"]
#define stat list
statList = ["str","int","wis","dex","cha","con","lck"]
#define search variables
valueOption = ""
valueSearch = None
genreSearch = None
classSearch = None
raceSearch = None
alignSearch = None
levelSearch = None
minlevelSearch = None
hpSearch = None
drSearch = None
hrSearch = None
manaSearch = None
strSearch = None
dexSearch = None
wisSearch = None
intSearch = None
conSearch = None
chaSearch = None
lckSearch = None
wearSearch = "none"
wearEntry = None
acSearch = None
searchResult = []
searchDict = eqDict.copy()
#GUI setup
root = Tk()
root.title('Realms of Despair Equipment Search by Moe')
root.geometry("500x750")
#dropdown class select
def searcheq():
#erase variables
valueOption = ""
valueSearch = None
genreSearch = None
classSearch = None
raceSearch = None
alignSearch = None
levelSearch = None
minlevelSearch = None
hpSearch = None
drSearch = None
hrSearch = None
manaSearch = None
strSearch = None
dexSearch = None
wisSearch = None
intSearch = None
conSearch = None
chaSearch = None
lckSearch = None
wearSearch = "none"
statSearch = None
statSearch2 = None
statSearch3 = None
acSearch = None
keywordSearch = None
searchResult = []
searchDict = eqDict.copy()
#set selected variables from GUI
if raceclick.get() is not None:
raceSearch = raceclick.get()
if valueEntry.get() != "":
valueOption = valueclick.get()
if valueEntry.get() != "":
valueSearch = int(valueEntry.get())
if hpEntry.get() != "":
if hpEntry.get() != "0":
hpSearch = int(hpEntry.get())
if wearclick is not None:
if wearclick.get() != "none":
wearSearch = wearclick.get()
if keywordEntry is not None:
if keywordEntry.get() != "":
keywordSearch = keywordEntry.get().lower()
if alignclick is not None:
if alignclick.get() != "none":
alignSearch = alignclick.get()
if levelEntry.get() != "":
if int(levelEntry.get()) < 50:
levelSearch = int(levelEntry.get())
if minlevelEntry.get() != "":
if int(minlevelEntry.get()) < 50:
minlevelSearch = int(minlevelEntry.get())
if acEntry.get() != "":
if acEntry.get() != "0":
acSearch = int(acEntry.get())
if statEntry.get() != "":
if statEntry.get() != "0":
statSearch = int(statEntry.get())
statType = statclick.get()
if statEntry2.get() != "":
if statEntry2.get() != "0":
statSearch2 = int(statEntry2.get())
statType2 = statclick2.get()
if statEntry3.get() != "":
if statEntry3.get() != "0":
statSearch3 = int(statEntry3.get())
statType3 = statclick3.get()
if manaEntry.get() != "":
if manaEntry.get() != "0":
manaSearch = int(manaEntry.get())
if drEntry.get() != "":
if drEntry.get() != "0":
drSearch = int(drEntry.get())
if hrEntry.get() != "":
if hrEntry.get() != "0":
hrSearch = int(hrEntry.get())
#class selection variables defined
if classclick.get() != "none":
if classclick.get() == "Augurer":
classSearch = "Augurer"
genreSearch = "sorcerer"
if classclick.get() == "Barbarian":
classSearch = "Barbarian"
genreSearch = "fighter"
if classclick.get() == "Bladesinger":
classSearch = "Bladesinger"
genreSearch = "rogue"
if classclick.get() == "Cleric":
classSearch = "Cleric"
genreSearch = "divinity"
if classclick.get() == "Druid":
classSearch = "Druid"
genreSearch = "shaman"
if classclick.get() == "Fathomer":
classSearch = "Fathomer"
genreSearch = "rogue"
if classclick.get() == "Mage":
classSearch = "Mage"
genreSearch = "sorcerer"
if classclick.get() == "Nephandi":
classSearch = "Nephandi"
genreSearch = "sorcerer"
if classclick.get() == "Paladin":
classSearch = "Paladin"
genreSearch = "fighter"
if classclick.get() == "Ranger":
classSearch = "Ranger"
genreSearch = "fighter"
if classclick.get() == "Thief":
classSearch = "Thief"
genreSearch = "rogue"
if classclick.get() == "Vampire":
classSearch = "Vampire"
genreSearch = "aberrant"
if classclick.get() == "Warrior":
classSearch = "Warrior"
genreSearch = "fighter"
#search and prune for genre+class
if genreSearch is not None and classSearch is not None:
for key, value in list(searchDict.items()):
e = re.search('Genres allowed\: (.*)', value)
f = re.search('Classes allowed\: (.*)', value)
if e is not None:
e = re.search('Genres allowed\: (.*)', value).group(1)
if f is not None:
f = re.search('Classes allowed\: (.*)', value).group(1)
if e is not None or f is not None:
if e is None:
e = "nil"
if f is None:
f = "nil"
if genreSearch not in e and classSearch not in f:
del searchDict[key]
#prune magic items if barb
if classSearch == "Barbarian":
for key, value in list(searchDict.items()):
g = re.search(r'Special properties\: (.*)', value)
if g is not None:
g = re.search(r'Special properties\: (.*)', value).group(1)
if g is None:
g = "nil"
if "magic" in g:
del searchDict[key]
#search for align and prune
if alignSearch is not None:
if alignSearch != "none":
for key, value in list(searchDict.items()):
e = re.search('Alignments allowed\: (.*)', value)
if e is not None:
e = re.search('Alignments allowed\: (.*)', value).group(1)
if alignSearch not in e:
del searchDict[key]
#search for keyword and prune
if keywordSearch is not None:
if keywordSearch != "":
for key, value in list(searchDict.items()):
if keywordSearch not in key.lower() and keywordSearch not in value.lower():
del searchDict[key]
# search and prune for value
if valueSearch is not None:
if valueSearch != "":
for key,value in list(searchDict.items()):
e = re.search(r'has a gold value of ([0-9]+).', value)
if e is not None:
e = re.search(r'has a gold value of ([0-9]+).', value).group(1)
if valueOption==">" and valueSearch > int(e):
del searchDict[key]
elif valueOption=="<" and valueSearch < int(e):
del searchDict[key]
#search and prune for max level
if levelSearch is not None:
for key, value in list(searchDict.items()):
e = re.search(r'It is a level (\d+)', value)
if e is not None:
e = re.search(r'It is a level (\d+)', value).group(1)
if levelSearch < int(e):
del searchDict[key]
# search and prune for minimum level
if minlevelSearch is not None:
for key, value in list(searchDict.items()):
e = re.search(r'It is a level (\d+)', value)
if e is not None:
e = re.search(r'It is a level (\d+)', value).group(1)
if minlevelSearch > int(e):
del searchDict[key]
# search and prune for pkill items
if pkillCheck.get() == 0:
for key, value in list(searchDict.items()):
e = re.search(r'Special properties\: (.*)', value)
if e is not None:
e = re.search(r'Special properties\: (.*)', value).group(1)
if "pkill" in e:
del searchDict[key]
#search for wearloc and prune
if wearSearch is not None:
if wearSearch != "":
if wearSearch != "none":
if wearSearch != "light":
for key, value in list(searchDict.items()):
e = re.search(r'Locations it can be worn\: (.*)', value)
if e is not None:
e = re.search(r'Locations it can be worn\: (.*)', value).group(1)
if wearSearch not in e:
del searchDict[key]
if e is None:
del searchDict[key]
if wearSearch == "light":
for key, value in list(searchDict.items()):
e = re.search(r'It is a level (\d+) (.*)\,', value)
if e is not None:
e = re.search(r'It is a level (\d+) (.*)\,', value).group(2)
if e != "light":
del searchDict[key]
#search and prune old style wearlocs
if wearSearch is not None:
if wearSearch != "":
for key, value in list(searchDict.items()):
e = re.search(r'with wear location\: (.*)', key)
if e is not None:
e = re.search(r'with wear location\: (.*)', key).group(1)
if wearSearch not in e:
del searchDict[key]
#search for races and prune
if raceSearch is not None:
if raceSearch != "none":
for key, value in list(searchDict.items()):
e = re.search('Races allowed\: (.*)', value)
if e is not None:
e = re.search('Races allowed\: (.*)', value).group(1)
if raceSearch not in e:
del searchDict[key]
#search for hp and prune
if hpSearch is not None:
for key, value in list(searchDict.items()):
e = re.search(r'Affects hp by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects hp by (\d+)', value).group(1)
if int(e) < hpSearch:
del searchDict[key]
#search for mana and prune
if manaSearch is not None:
for key, value in list(searchDict.items()):
e = re.search(r'Affects mana by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects mana by (\d+)', value).group(1)
if int(e) < manaSearch:
del searchDict[key]
#search for AC and prune
if acSearch is not None:
for key, value in list(searchDict.items()):
e = re.search(r'Armor class is (\d+) of (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Armor class is (\d+) of (\d+)', value).group(2)
if int(e) < acSearch:
del searchDict[key]
#search for DR and prune
if drSearch is not None:
for key, value in list(searchDict.items()):
e = re.search(r'Affects damage roll by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects damage roll by (\d+)', value).group(1)
if int(e) < drSearch:
del searchDict[key]
#search for HR and prune
if hrSearch is not None:
for key, value in list(searchDict.items()):
e = re.search(r'Affects hit roll by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects hit roll by (\d+)', value).group(1)
if int(e) < hrSearch:
del searchDict[key]
#FIRST STAT SEARCH SECTION
#search for STR and prune
if statSearch is not None:
if statType == "str":
for key, value in list(searchDict.items()):
e = re.search(r'Affects strength by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects strength by (\d+)', value).group(1)
if int(e) < statSearch:
del searchDict[key]
#search for DEX and prune
if statSearch is not None:
if statType == "dex":
for key, value in list(searchDict.items()):
e = re.search(r'Affects dexterity by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects dexterity by (\d+)', value).group(1)
if int(e) < statSearch:
del searchDict[key]
#search for WIS and prune
if statSearch is not None:
if statType == "wis":
for key, value in list(searchDict.items()):
e = re.search(r'Affects wisdom by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects wisdom by (\d+)', value).group(1)
if int(e) < statSearch:
del searchDict[key]
#search for INT and prune
if statSearch is not None:
if statType == "int":
for key, value in list(searchDict.items()):
e = re.search(r'Affects intelligence by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects intelligence by (\d+)', value).group(1)
if int(e) < statSearch:
del searchDict[key]
#search for CON and prune
if statSearch is not None:
if statType == "con":
for key, value in list(searchDict.items()):
e = re.search(r'Affects constitution by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects constitution by (\d+)', value).group(1)
if int(e) < statSearch:
del searchDict[key]
#search for CHA and prune
if statSearch is not None:
if statType == "cha":
for key, value in list(searchDict.items()):
e = re.search(r'Affects charisma by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects charisma by (\d+)', value).group(1)
if int(e) < statSearch:
del searchDict[key]
#search for LCK and prune
if statSearch is not None:
if statType == "lck":
for key, value in list(searchDict.items()):
e = re.search(r'Affects luck by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects luck by (\d+)', value).group(1)
if int(e) < statSearch:
del searchDict[key]
#SECOND STAT SEARCH SECTION
#search for STR and prune
if statSearch2 is not None:
if statType2 == "str":
for key, value in list(searchDict.items()):
e = re.search(r'Affects strength by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects strength by (\d+)', value).group(1)
if int(e) < statSearch2:
del searchDict[key]
#search for DEX and prune
if statSearch2 is not None:
if statType2 == "dex":
for key, value in list(searchDict.items()):
e = re.search(r'Affects dexterity by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects dexterity by (\d+)', value).group(1)
if int(e) < statSearch2:
del searchDict[key]
#search for WIS and prune
if statSearch2 is not None:
if statType2 == "wis":
for key, value in list(searchDict.items()):
e = re.search(r'Affects wisdom by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects wisdom by (\d+)', value).group(1)
if int(e) < statSearch2:
del searchDict[key]
#search for INT and prune
if statSearch2 is not None:
if statType2 == "int":
for key, value in list(searchDict.items()):
e = re.search(r'Affects intelligence by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects intelligence by (\d+)', value).group(1)
if int(e) < statSearch2:
del searchDict[key]
#search for CON and prune
if statSearch2 is not None:
if statType2 == "con":
for key, value in list(searchDict.items()):
e = re.search(r'Affects constitution by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects constitution by (\d+)', value).group(1)
if int(e) < statSearch2:
del searchDict[key]
#search for CHA and prune
if statSearch2 is not None:
if statType2 == "cha":
for key, value in list(searchDict.items()):
e = re.search(r'Affects charisma by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects charisma by (\d+)', value).group(1)
if int(e) < statSearch2:
del searchDict[key]
#search for LCK and prune
if statSearch2 is not None:
if statType2 == "lck":
for key, value in list(searchDict.items()):
e = re.search(r'Affects luck by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects luck by (\d+)', value).group(1)
if int(e) < statSearch2:
del searchDict[key]
#THIRD STAT SEARCH SECTION
#search for STR and prune
if statSearch3 is not None:
if statType3 == "str":
for key, value in list(searchDict.items()):
e = re.search(r'Affects strength by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects strength by (\d+)', value).group(1)
if int(e) < statSearch3:
del searchDict[key]
#search for DEX and prune
if statSearch3 is not None:
if statType3 == "dex":
for key, value in list(searchDict.items()):
e = re.search(r'Affects dexterity by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects dexterity by (\d+)', value).group(1)
if int(e) < statSearch3:
del searchDict[key]
#search for WIS and prune
if statSearch3 is not None:
if statType3 == "wis":
for key, value in list(searchDict.items()):
e = re.search(r'Affects wisdom by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects wisdom by (\d+)', value).group(1)
if int(e) < statSearch3:
del searchDict[key]
#search for INT and prune
if statSearch3 is not None:
if statType3 == "int":
for key, value in list(searchDict.items()):
e = re.search(r'Affects intelligence by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects intelligence by (\d+)', value).group(1)
if int(e) < statSearch3:
del searchDict[key]
#search for CON and prune
if statSearch3 is not None:
if statType3 == "con":
for key, value in list(searchDict.items()):
e = re.search(r'Affects constitution by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects constitution by (\d+)', value).group(1)
if int(e) < statSearch3:
del searchDict[key]
#search for CHA and prune
if statSearch3 is not None:
if statType3 == "cha":
for key, value in list(searchDict.items()):
e = re.search(r'Affects charisma by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects charisma by (\d+)', value).group(1)
if int(e) < statSearch3:
del searchDict[key]
#search for LCK and prune
if statSearch3 is not None:
if statType3 == "lck":
for key, value in list(searchDict.items()):
e = re.search(r'Affects luck by (\d+)', value)
if e is None:
del searchDict[key]
else:
e = re.search(r'Affects luck by (\d+)', value).group(1)
if int(e) < statSearch3:
del searchDict[key]
#parse searchDict to display results
searchList = searchDict.keys()
for value in searchList:
e = re.search(r"Object \'(.*)\' is", value)
if e is not None:
e = re.search(r"Object \'(.*)\' is", value).group(1)
searchResult.append(e)
#clean up parsed search and turn into list for tkinter
searchResult = str(searchResult)
searchResult = searchResult.strip(']')
searchResult = searchResult.strip('[')
searchResult = searchResult.replace('"',"'")
searchResult = searchResult[1:-1]
searchResult = searchResult.split("', '")
#populate listbox window
searchList1 = StringVar()
searchList1.set(searchResult)
resultWindow = Listbox(root, width=60, height=15, listvariable=searchList1)
resultWindow.grid(row=12, column=1, columnspan=4)
#make items clickable
resultWindow.bind("<<ListboxSelect>>", listclick)
resultWindow.bind('<3>', lambda e: context_menu(e, menu))
#set up empty results display
identifyWindow = Text(root, width=60, height=15)
identifyWindow.grid(row=13, column=1, columnspan=4)
resultWindow = Listbox(root, width=60, height=15)
resultWindow.grid(row=12, column=1, columnspan=4)
#define listclick function for resultWindow to print identify when clicked
def listclick(event):
selection = event.widget.curselection()
if selection:
index = selection[0]
global itemName
itemName = event.widget.get(index)
itemDisp = [val for key, val in eqDict.items() if "\'" + itemName in key.replace('"',"'")]
identifyWindow.delete('1.0', END)
identifyWindow.insert(END, (', '.join(itemDisp)))
#class selection button
classText = StringVar()
classText.set("Class")
classDir = Label(root, textvariable=classText, height = 1)
classDir.grid(row=1, column=1, sticky=E)
classclick = StringVar()
classclick.set("")
classSelect = OptionMenu(root, classclick, *classList)
classSelect.grid(row=1, column=2, sticky=W)
#race selection button
raceText = StringVar()
raceText.set("Race")
raceDir = Label(root, textvariable=raceText, height = 1)
raceDir.grid(row=2, column=1, sticky=E)
raceclick = StringVar()
raceclick.set("")
raceSelect = OptionMenu(root, raceclick, *raceList)
raceSelect.grid(row=2, column=2, sticky=W)
#wearloc selection button
wearText = StringVar()
wearText.set("Wear Loc")
wearDir = Label(root, textvariable=wearText, height = 1)
wearDir.grid(row=3, column=1, sticky=E)
wearclick = StringVar()
wearclick.set("")
wearSelect = OptionMenu(root, wearclick, *wearList)
wearSelect.grid(row=3, column=2, sticky=W)
#align selection button
alignText = StringVar()
alignText.set("Align")
alignDir = Label(root, textvariable=alignText, height = 1)
alignDir.grid(row=4, column=1, sticky=E)
alignclick = StringVar()
alignclick.set("")
alignSelect = OptionMenu(root, alignclick, *alignList)
alignSelect.grid(row=4, column=2, sticky=W)
#wildcard keyword search
keywordText = StringVar()
keywordText.set("Keyword")
keywordDir = Label(root, textvariable=keywordText, height=1)
keywordDir.grid(row=5, column=1, sticky=E)
keywordEntry = Entry(root, width=15)
keywordEntry.grid(row=5, column=2, sticky=W)
#pkill item checkbox
pkillText = StringVar()
pkillText.set("Include Pkill?")
pkillDir = Label(root, textvariable=pkillText, height=1)
pkillDir.grid(row=8, column=3, sticky=E)
pkillCheck = IntVar()
pkBox = Checkbutton(root, text='', variable=pkillCheck, onvalue=1, offvalue=0)
pkBox.grid(row=8, column=4, sticky=W)
#level entry box
levelText = StringVar()
levelText.set("Max Level")
levelDir = Label(root, textvariable=levelText, height = 1)
levelDir.grid(row=1, column=3, sticky=E)
levelEntry = Entry(root, width=3)
levelEntry.grid(row=1, column=4, sticky=W)
#minlevel entry box
minlevelText = StringVar()
minlevelText.set("Min Level")
minlevelDir = Label(root, textvariable=minlevelText, height = 1)
minlevelDir.grid(row=2, column=3, sticky=E)
minlevelEntry = Entry(root, width=3)
minlevelEntry.grid(row=2, column=4, sticky=W)
#AC entry box
acText = StringVar()
acText.set("Armor AC")
acDir = Label(root, textvariable=acText, height = 1)
acDir.grid(row=3, column=3, sticky=E)
acEntry = Entry(root, width=3)
acEntry.grid(row=3, column=4, sticky=W)
#hp entry box
hpText = StringVar()
hpText.set("Hitpoints")
hpDir = Label(root, textvariable=hpText, height = 1)
hpDir.grid(row=4, column=3, sticky=E)
hpEntry = Entry(root, width=3)
hpEntry.grid(row=4, column=4, sticky=W)
#mana entry box
manaText = StringVar()
manaText.set("Mana")
manaDir = Label(root, textvariable=manaText, height = 1)
manaDir.grid(row=5,column=3, sticky=E)
manaEntry= Entry(root, width=3)
manaEntry.grid(row=5,column=4, sticky=W)
#stat selection button #1
statclick = StringVar()
statclick.set("str")
statSelect = OptionMenu(root, statclick, *statList)
statSelect.grid(row=6, column=1, sticky=E)
statEntry = Entry(root, width=3)
statEntry.grid(row=6, column=2, sticky=W)
#stat selection button #2
statclick2 = StringVar()
statclick2.set("str")
statSelect2 = OptionMenu(root, statclick2, *statList)
statSelect2.grid(row=7, column=1, sticky=E)
statEntry2 = Entry(root, width=3)
statEntry2.grid(row=7, column=2, sticky=W)
#stat selection button #3
statclick3 = StringVar()
statclick3.set("str")
statSelect3 = OptionMenu(root, statclick3, *statList)
statSelect3.grid(row=8, column=1, sticky=E)
statEntry3 = Entry(root, width=3)
statEntry3.grid(row=8, column=2, sticky=W)
# value selection buttons
valueLabel = StringVar()
valueLabel.set("Value")
valueclick = StringVar()
valueclick.set(">")
valueLabel = Label(root, textvariable=valueLabel, height = 1)
valueLabel.grid(row=9, column=1)
valueSelect = OptionMenu(root, valueclick, *[">", "<"])
valueSelect.grid(row=9, column=1, sticky=E)
valueEntry = Entry(root, width=10)
valueEntry.grid(row=9, column=2, sticky=W)
#DR entry box
drText = StringVar()
drText.set("DamRoll")
drDir = Label(root, textvariable=drText, height = 1)
drDir.grid(row=6,column=3, sticky=E)
drEntry= Entry(root, width=3)
drEntry.grid(row=6,column=4, sticky=W)
#HR entry box
hrText = StringVar()
hrText.set("HitRoll")
hrDir = Label(root, textvariable=hrText, height = 1)
hrDir.grid(row=7,column=3, sticky=E)
hrEntry= Entry(root, width=3)
hrEntry.grid(row=7,column=4, sticky=W)
#display number of items in DB
itemNum = StringVar()
itemNum.set("Searching " + str(len(eqDict)) + " items")
itemDir = Label(root, textvariable=itemNum, height = 1)
itemDir.grid(row=11,column=1, sticky=E)
#search button
searchButton = Button(root, text="Search", command=searcheq).grid(row=11, column=4, sticky=E)
#right click on results to go to web page
def wiki_open():
global wikiLink
first, rest = itemName.split(None, 1)
if first in {'A', 'An', 'The'}:
wikiLink = rest + ', ' + first
wikiLink = wikiLink.replace(" ","_")
else: wikiLink = itemName
webbrowser.open_new_tab('http://rodpedia.realmsofdespair.info/wiki/' + wikiLink)
def copy_text():
root.clipboard_clear()
root.clipboard_append(itemName)
root.update()
menu = Menu(tearoff=0)
menu.add_command(label=u'View on Wiki', command=wiki_open)
menu.add_command(label=u'Copy', command=copy_text)
def context_menu(event, menu):
menuwidget = event.widget
menuindex = menuwidget.nearest(event.y)
_, yoffset, _, height = menuwidget.bbox(menuindex)
if event.y > height + yoffset + 5: # XXX 5 is a niceness factor :)
# Outside of widget.
return
menuitem = menuwidget.get(menuindex)
menu.post(event.x_root, event.y_root)
root.mainloop()