Skip to content

Commit c6f6ab5

Browse files
committed
Update main.py
Linux icon
1 parent 3a05fbf commit c6f6ab5

File tree

1 file changed

+92
-33
lines changed

1 file changed

+92
-33
lines changed

main.py

Lines changed: 92 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ def About():
7171
top.geometry('310x240')
7272
top.title('About')
7373
try: top.iconbitmap('ObsPlanner.ico') #win
74-
except: pass
74+
except:
75+
try: #linux
76+
img=tk.Image('photo',file='ObsPlanner.png')
77+
top.tk.call('wm','iconphoto',top._w,img)
78+
except: pass
7579
top.resizable(False,False)
7680
top.configure(background=colors['window'])
7781

@@ -208,12 +212,16 @@ def detect():
208212
messagebox.showwarning('Constellation','Multiple possible constellations detected ('+', '.join(found)+')! Please, add it manually.')
209213
top.lift()
210214

211-
top=tk.Tk()
215+
top=tk.Toplevel()
212216
top.lift()
213217
top.geometry('250x350')
214218
top.title('Object')
215219
try: top.iconbitmap('ObsPlanner.ico') #win
216-
except: pass
220+
except:
221+
try: #linux
222+
img=tk.Image('photo',file='ObsPlanner.png')
223+
top.tk.call('wm','iconphoto',top._w,img)
224+
except: pass
217225
top.resizable(False,False)
218226
top.configure(background=colors['window'])
219227

@@ -400,12 +408,17 @@ def saveObs():
400408
topObs.destroy()
401409
top.lift()
402410

403-
topObs=tk.Tk()
411+
topObs=tk.Toplevel()
404412
topObs.lift()
405413
topObs.geometry('300x80')
406414
topObs.title('Observer')
407415
try: topObs.iconbitmap('ObsPlanner.ico') #win
408-
except: pass
416+
except:
417+
try: #linux
418+
img=tk.Image('photo',file='ObsPlanner.png')
419+
topObs.tk.call('wm','iconphoto',topObs._w,img)
420+
except: pass
421+
topObs.configure(background=colors['window'])
409422
topObs.resizable(False,False)
410423

411424
obsNameVar=tk.StringVar(topObs)
@@ -446,12 +459,17 @@ def saveLims():
446459
topLims.destroy()
447460
topSite.lift()
448461

449-
topLims=tk.Tk()
462+
topLims=tk.Toplevel()
450463
topLims.lift()
451464
topLims.geometry('400x150')
452465
topLims.title('Limits')
453466
try: topLims.iconbitmap('ObsPlanner.ico') #win
454-
except: pass
467+
except:
468+
try: #linux
469+
img=tk.Image('photo',file='ObsPlanner.png')
470+
topLims.tk.call('wm','iconphoto',topLims._w,img)
471+
except: pass
472+
topLims.configure(background=colors['window'])
455473
topLims.resizable(False,False)
456474

457475
minAltVar=tk.DoubleVar(topLims)
@@ -550,12 +568,17 @@ def saveSite():
550568
topSite.destroy()
551569
top.lift()
552570

553-
topSite=tk.Tk()
571+
topSite=tk.Toplevel()
554572
topSite.lift()
555573
topSite.geometry('230x200')
556574
topSite.title('Site')
557575
try: topSite.iconbitmap('ObsPlanner.ico') #win
558-
except: pass
576+
except:
577+
try: #linux
578+
img=tk.Image('photo',file='ObsPlanner.png')
579+
topSite.tk.call('wm','iconphoto',topSite._w,img)
580+
except: pass
581+
topSite.configure(background=colors['window'])
559582
topSite.resizable(False,False)
560583

561584
siteNameVar=tk.StringVar(topSite)
@@ -650,12 +673,17 @@ def saveTel():
650673
topTel.destroy()
651674
top.lift()
652675

653-
topTel=tk.Tk()
676+
topTel=tk.Toplevel()
654677
topTel.lift()
655678
topTel.geometry('400x80')
656679
topTel.title('Telescope')
657680
try: topTel.iconbitmap('ObsPlanner.ico') #win
658-
except: pass
681+
except:
682+
try: #linux
683+
img=tk.Image('photo',file='ObsPlanner.png')
684+
topTel.tk.call('wm','iconphoto',topTel._w,img)
685+
except: pass
686+
topTel.configure(background=colors['window'])
659687
topTel.resizable(False,False)
660688

661689
telNameVar=tk.StringVar(topTel)
@@ -760,12 +788,17 @@ def detect():
760788
constVar.set(const)
761789
return
762790

763-
topObj=tk.Tk()
791+
topObj=tk.Toplevel()
764792
topObj.lift()
765793
topObj.geometry('250x350')
766794
topObj.title('Object')
767795
try: topObj.iconbitmap('ObsPlanner.ico') #win
768-
except: pass
796+
except:
797+
try: #linux
798+
img=tk.Image('photo',file='ObsPlanner.png')
799+
topObj.tk.call('wm','iconphoto',topObj._w,img)
800+
except: pass
801+
topObj.configure(background=colors['window'])
769802
topObj.resizable(False,False)
770803

771804
nameVar=tk.StringVar(topObj)
@@ -980,12 +1013,17 @@ def saveObs():
9801013
top.destroy()
9811014
root.lift()
9821015

983-
top=tk.Tk()
1016+
top=tk.Toplevel()
9841017
top.lift()
9851018
top.geometry('450x400')
9861019
top.title('Observation')
9871020
try: top.iconbitmap('ObsPlanner.ico') #win
988-
except: pass
1021+
except:
1022+
try: #linux
1023+
img=tk.Image('photo',file='ObsPlanner.png')
1024+
top.tk.call('wm','iconphoto',top._w,img)
1025+
except: pass
1026+
top.configure(background=colors['window'])
9891027
top.resizable(False,False)
9901028

9911029
observerVar=tk.StringVar(top)
@@ -1327,12 +1365,17 @@ def saveObs():
13271365
topObs.destroy()
13281366
top.lift()
13291367

1330-
topObs=tk.Tk()
1368+
topObs=tk.Toplevel()
13311369
topObs.lift()
13321370
topObs.geometry('300x80')
13331371
topObs.title('Observer')
13341372
try: topObs.iconbitmap('ObsPlanner.ico') #win
1335-
except: pass
1373+
except:
1374+
try: #linux
1375+
img=tk.Image('photo',file='ObsPlanner.png')
1376+
topObs.tk.call('wm','iconphoto',topObs._w,img)
1377+
except: pass
1378+
topObs.configure(background=colors['window'])
13361379
topObs.resizable(False,False)
13371380

13381381
obsNameVar=tk.StringVar(topObs)
@@ -1381,13 +1424,18 @@ def saveLims():
13811424
topLims.destroy()
13821425
topSite.lift()
13831426

1384-
topLims=tk.Tk()
1427+
topLims=tk.Toplevel()
13851428
topLims.lift()
13861429
topLims.geometry('400x150')
13871430
topLims.title('Limits')
13881431
topLims.resizable(False,False)
13891432
try: topLims.iconbitmap('ObsPlanner.ico') #win
1390-
except: pass
1433+
except:
1434+
try: #linux
1435+
img=tk.Image('photo',file='ObsPlanner.png')
1436+
topLims.tk.call('wm','iconphoto',topLims._w,img)
1437+
except: pass
1438+
topLims.configure(background=colors['window'])
13911439

13921440
minAltVar=tk.DoubleVar(topLims)
13931441
maxAltVar=tk.DoubleVar(topLims)
@@ -1487,12 +1535,17 @@ def saveSite():
14871535
topSite.destroy()
14881536
top.lift()
14891537

1490-
topSite=tk.Tk()
1538+
topSite=tk.Toplevel()
14911539
topSite.lift()
14921540
topSite.geometry('230x200')
14931541
topSite.title('Site')
14941542
try: topSite.iconbitmap('ObsPlanner.ico') #win
1495-
except: pass
1543+
except:
1544+
try: #linux
1545+
img=tk.Image('photo',file='ObsPlanner.png')
1546+
topSite.tk.call('wm','iconphoto',topSite._w,img)
1547+
except: pass
1548+
topSite.configure(background=colors['window'])
14961549
topSite.resizable(False,False)
14971550

14981551
siteNameVar=tk.StringVar(topSite)
@@ -1598,12 +1651,17 @@ def saveTel():
15981651
topTel.destroy()
15991652
top.lift()
16001653

1601-
topTel=tk.Tk()
1654+
topTel=tk.Toplevel()
16021655
topTel.lift()
16031656
topTel.geometry('400x80')
16041657
topTel.title('Telescope')
16051658
try: topTel.iconbitmap('ObsPlanner.ico') #win
1606-
except: pass
1659+
except:
1660+
try: #linux
1661+
img=tk.Image('photo',file='ObsPlanner.png')
1662+
topTel.tk.call('wm','iconphoto',topTel._w,img)
1663+
except: pass
1664+
topTel.configure(background=colors['window'])
16071665
topTel.resizable(False,False)
16081666

16091667
telNameVar=tk.StringVar(topTel)
@@ -1681,12 +1739,17 @@ def saveSet():
16811739
top.destroy()
16821740
root.lift()
16831741

1684-
top=tk.Tk()
1742+
top=tk.Toplevel()
16851743
top.lift()
16861744
top.geometry('530x200')
16871745
top.title('Settings')
16881746
try: top.iconbitmap('ObsPlanner.ico') #win
1689-
except: pass
1747+
except:
1748+
try: #linux
1749+
img=tk.Image('photo',file='ObsPlanner.png')
1750+
top.tk.call('wm','iconphoto',top._w,img)
1751+
except: pass
1752+
top.configure(background=colors['window'])
16901753
top.resizable(False,False)
16911754

16921755
settings1=copy.deepcopy(settings)
@@ -2383,7 +2446,6 @@ def obsselect(evt):
23832446
Text1.configure(width=256)
23842447
Text1.configure(wrap=tk.WORD)
23852448

2386-
#TODO focus color?
23872449
Button3_2=tk.Button(Labelframe0)
23882450
Button3_2.place(relx=0.05,rely=0.95,height=24,width=47)
23892451
Button3_2.configure(command=AddObj)
@@ -2525,19 +2587,20 @@ def obsselect(evt):
25252587
canvas1=FigureCanvasTkAgg(figObj,frame1)
25262588
canvas1.get_tk_widget().pack(side='top',fill='both',expand=1)
25272589

2528-
#TODO focus color?, disabled color?
25292590
#menu
25302591
Popupmenu1=tk.Menu(root,tearoff=0)
25312592
Popupmenu1.configure(background=colors['window'])
25322593
Popupmenu1.configure(fg=colors['text'])
2594+
if colors['text']=='red':
2595+
Popupmenu1.configure(activebackground=colors['select_bg'])
2596+
Popupmenu1.configure(activeforeground=colors['select_text'])
25332597

25342598
fileM=tk.Menu(Popupmenu1,tearoff=0)
25352599
fileM.configure(background=colors['window'])
25362600
fileM.configure(fg=colors['text'])
25372601
if colors['text']=='red':
25382602
fileM.configure(activebackground=colors['select_bg'])
25392603
fileM.configure(activeforeground=colors['select_text'])
2540-
#fileM.configure(inactiveselectbackground=colors['select_bg'])
25412604
Popupmenu1.add_cascade(menu=fileM,label='File')
25422605
fileM.add_command(command=NewFile,label='New',accelerator='Ctrl+N')
25432606
root.bind('<Control-n>',NewFile)
@@ -2553,10 +2616,10 @@ def obsselect(evt):
25532616
import_export=tk.Menu(Popupmenu1,tearoff=0)
25542617
import_export.configure(background=colors['window'])
25552618
import_export.configure(fg=colors['text'])
2619+
import_export.configure(disabledforeground=colors['text_dis'])
25562620
if colors['text']=='red':
25572621
import_export.configure(activebackground=colors['select_bg'])
25582622
import_export.configure(activeforeground=colors['select_text'])
2559-
#import_export.configure(inactiveselectbackground=colors['select_bg'])
25602623
Popupmenu1.add_cascade(menu=import_export,label='Import/Export')
25612624

25622625
importMenu=tk.Menu(import_export,tearoff=0)
@@ -2565,7 +2628,6 @@ def obsselect(evt):
25652628
if colors['text']=='red':
25662629
importMenu.configure(activebackground=colors['select_bg'])
25672630
importMenu.configure(activeforeground=colors['select_text'])
2568-
#importMenu.configure(inactiveselectbackground=colors['select_bg'])
25692631
import_export.add_cascade(menu=importMenu,label='Import Objects')
25702632
importMenu.add_command(label='from APT',command=aptI)
25712633
importMenu.add_command(label='from AstroPlanner',command=plannerI)
@@ -2582,7 +2644,6 @@ def obsselect(evt):
25822644
if colors['text']=='red':
25832645
exportObj.configure(activebackground=colors['select_bg'])
25842646
exportObj.configure(activeforeground=colors['select_text'])
2585-
#exportObj.configure(inactiveselectbackground=colors['select_bg'])
25862647
exportObj.configure(disabledforeground=colors['text_dis'])
25872648
import_export.add_cascade(menu=exportObj,label='Export Selected Objects',state=tk.DISABLED)
25882649
exportObj.add_command(label='to APT',command=aptE)
@@ -2598,7 +2659,6 @@ def obsselect(evt):
25982659
if colors['text']=='red':
25992660
exportObs.configure(activebackground=colors['select_bg'])
26002661
exportObs.configure(activeforeground=colors['select_text'])
2601-
#exportObs.configure(inactiveselectbackground=colors['select_bg'])
26022662
exportObs.configure(disabledforeground=colors['text_dis'])
26032663
import_export.add_cascade(menu=exportObs,label='Export Observations of Object',state=tk.DISABLED)
26042664
exportObs.add_command(label='to Excel',command=excelObsE)
@@ -2610,7 +2670,6 @@ def obsselect(evt):
26102670
if colors['text']=='red':
26112671
exportObsAll.configure(activebackground=colors['select_bg'])
26122672
exportObsAll.configure(activeforeground=colors['select_text'])
2613-
#exportObsAll.configure(inactiveselectbackground=colors['select_bg'])
26142673
exportObsAll.configure(disabledforeground=colors['text_dis'])
26152674
import_export.add_cascade(menu=exportObsAll,label='Export All Observations',state=tk.DISABLED)
26162675
exportObsAll.add_command(label='to Excel',command=excelObsAllE)

0 commit comments

Comments
 (0)