ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Gromulus/Gromulus_UI.py
Revision: 795
Committed: Fri Sep 8 15:11:11 2023 UTC (2 years, 6 months ago) by nino.borges
Content type: text/x-python
File size: 9941 byte(s)
Log Message:
Gromulus, which is a catalog inventory for roms, games and maybe one day applications.

File Contents

# User Rev Content
1 nino.borges 795 """
2     Created by Emanuel Borges
3     05.19.2023
4    
5     This is the main UI for Gromulus, which is a catalog inventory for roms, games and maybe one day applications.
6     Like most of my GUI programs, this will import a separate library with my methods for doing the actual work.
7    
8     """
9    
10    
11     import sys, os, wx
12     #import wx.lib.buttons as buttons
13     import Gromulus_Lib
14    
15    
16    
17     class MyFrame(wx.Frame):
18     def __init__(self, parent, ID, title, pos=wx.DefaultPosition):
19     wx.Frame.__init__(self, parent, ID, title, pos, size = (1450,525))
20     #db = Gromulus_Lib()
21     self.panel = wx.Panel(self,-1)
22     self.gamesListMatrix = Gromulus_Lib.GetGameListBySystem('snes')
23     gamesList = list(self.gamesListMatrix.keys())
24     gamesList.sort()
25    
26     self.CreateSystemButtonSection()
27     self.gameSelectionListBox = wx.ListBox(self.panel, 60, (100, 50), (490, 320), gamesList , wx.LB_SINGLE|wx.LB_OWNERDRAW)
28     self.CreateFieldsFirstRow()
29    
30    
31    
32     mainSizer = wx.BoxSizer(wx.HORIZONTAL)
33     mainSizer.Add(self.buttonSizer, 0, wx.ALIGN_TOP|wx.LEFT|wx.TOP,25)
34     mainSizer.Add(self.gameSelectionListBox, 0, wx.ALIGN_TOP|wx.LEFT|wx.TOP,25)
35     mainSizer.Add(self.fieldsFirstRowSizer, 0, wx.ALIGN_TOP|wx.LEFT|wx.TOP,25)
36     self.panel.SetSizer(mainSizer)
37    
38    
39     self.CreateStatusBar()
40     self.SetStatusText("Ready.")
41     self.CreateMenuBar()
42    
43     self.Bind(wx. EVT_TOGGLEBUTTON, self.OnSystemSelected, self.snesSystemButton)
44     self.Bind(wx. EVT_TOGGLEBUTTON, self.OnSystemSelected, self.nesSystemButton)
45     self.Bind(wx. EVT_TOGGLEBUTTON, self.OnSystemSelected, self.genesisSystemButton)
46     self.Bind(wx. EVT_TOGGLEBUTTON, self.OnSystemSelected, self.fz1SystemButton)
47     self.Bind(wx. EVT_TOGGLEBUTTON, self.OnSystemSelected, self.ps1SystemButton)
48    
49     self.Bind(wx.EVT_LISTBOX, self.OnGameSelected, self.gameSelectionListBox)
50    
51    
52     def CreateSystemButtonSection(self):
53     #systemsList = ['SNES','NES','Genisys']
54     #for system in systemsList:
55     #self.snesSystemButton = buttons.GenToggleButton(self.panel, -1, "SNES")
56     #self.nesSystemButton = buttons.GenToggleButton(self.panel, -1, "NES")
57     #self.genesisSystemButton = buttons.GenToggleButton(self.panel, -1, "Genesis")
58     #self.ps1SystemButton = buttons.GenToggleButton(self.panel, -1, "Playstation")
59    
60     ## Create a dictionary that holds the button instances by label text, so that you can toggle the other ones off in the bind event.
61     self.systemButtonDict = {}
62     self.snesSystemButton = wx.ToggleButton(self.panel, -1, "SNES")
63     self.systemButtonDict[self.snesSystemButton.GetLabelText()] = self.snesSystemButton
64    
65     self.nesSystemButton = wx.ToggleButton(self.panel, -1, "NES")
66     self.systemButtonDict[self.nesSystemButton.GetLabelText()] = self.nesSystemButton
67    
68     self.genesisSystemButton = wx.ToggleButton(self.panel, -1, "Genesis")
69     self.systemButtonDict[self.genesisSystemButton.GetLabelText()] = self.genesisSystemButton
70    
71     self.fz1SystemButton = wx.ToggleButton(self.panel, -1, "3DO")
72     self.systemButtonDict[self.fz1SystemButton.GetLabelText()] = self.fz1SystemButton
73    
74     self.ps1SystemButton = wx.ToggleButton(self.panel, -1, "Playstation")
75     self.systemButtonDict[self.ps1SystemButton.GetLabelText()] = self.ps1SystemButton
76    
77    
78     self.buttonSizer = wx.BoxSizer(wx.VERTICAL)
79     self.buttonSizer.Add(self.snesSystemButton, 0, wx.ALL,10)
80     self.buttonSizer.Add(self.nesSystemButton,0,wx.ALL,10)
81     self.buttonSizer.Add(self.genesisSystemButton,0,wx.ALL,10)
82     self.buttonSizer.Add(self.fz1SystemButton,0,wx.ALL,10)
83     self.buttonSizer.Add(self.ps1SystemButton,0,wx.ALL,10)
84    
85     def CreateFieldsFirstRow(self):
86     self.gameNameStaticText = wx.StaticText(self.panel, -1, "Game Name:")
87     self.gameNameTextCtrl = wx.TextCtrl(self.panel, -1, size=(325, -1))
88    
89     self.gameHashStaticText = wx.StaticText(self.panel, -1, "Game Hash:")
90     self.gameHashTextCtrl = wx.TextCtrl(self.panel, -1, size=(325, -1))
91    
92     self.gameFileNameStaticText = wx.StaticText(self.panel, -1, "Game File Name:")
93     self.gameFileNameTextCtrl = wx.TextCtrl(self.panel, -1, size=(325, -1))
94    
95     self.gameFilePathStaticText = wx.StaticText(self.panel, -1, "Game File Path:")
96     self.gameFilePathTextCtrl = wx.TextCtrl(self.panel, -1, size=(425, -1))
97    
98     self.noIntroGameNameStaticText = wx.StaticText(self.panel, -1, "No Intro Game Name:")
99     self.noIntroGameNameTextCtrl = wx.TextCtrl(self.panel, -1, size=(325, -1))
100    
101     self.noIntroSystemNameStaticText = wx.StaticText(self.panel, -1, "No Intro System:")
102     self.noIntroSystemNameTextCtrl = wx.TextCtrl(self.panel, -1, size=(380, -1))
103    
104     self.gameNameSizer = wx.BoxSizer(wx.HORIZONTAL)
105     self.gameNameSizer.Add(self.gameNameStaticText,0,wx.ALL, 10)
106     self.gameNameSizer.Add(self.gameNameTextCtrl,0,wx.ALL, 10)
107    
108     self.gameHashSizer = wx.BoxSizer(wx.HORIZONTAL)
109     self.gameHashSizer.Add(self.gameHashStaticText,0,wx.ALL, 10)
110     self.gameHashSizer.Add(self.gameHashTextCtrl,0,wx.ALL, 10)
111    
112     self.gameFileNameSizer = wx.BoxSizer(wx.HORIZONTAL)
113     self.gameFileNameSizer.Add(self.gameFileNameStaticText,0,wx.ALL, 10)
114     self.gameFileNameSizer.Add(self.gameFileNameTextCtrl,0,wx.ALL, 10)
115    
116     self.gameFilePathSizer = wx.BoxSizer(wx.HORIZONTAL)
117     self.gameFilePathSizer.Add(self.gameFilePathStaticText,0,wx.ALL, 10)
118     self.gameFilePathSizer.Add(self.gameFilePathTextCtrl,0,wx.ALL, 10)
119    
120     self.noIntroGameNameSizer = wx.BoxSizer(wx.HORIZONTAL)
121     self.noIntroGameNameSizer.Add(self.noIntroGameNameStaticText,0,wx.ALL, 10)
122     self.noIntroGameNameSizer.Add(self.noIntroGameNameTextCtrl,0,wx.ALL, 10)
123    
124     self.noIntroSystemNameSizer = wx.BoxSizer(wx.HORIZONTAL)
125     self.noIntroSystemNameSizer.Add(self.noIntroSystemNameStaticText,0,wx.ALL, 10)
126     self.noIntroSystemNameSizer.Add(self.noIntroSystemNameTextCtrl,0,wx.ALL, 10)
127    
128     self.fieldsFirstRowSizer = wx.BoxSizer(wx.VERTICAL)
129     self.fieldsFirstRowSizer.Add(self.gameNameSizer,0,wx.ALL, 10)
130     self.fieldsFirstRowSizer.Add(self.gameHashSizer,0,wx.ALL, 10)
131     self.fieldsFirstRowSizer.Add(self.gameFileNameSizer,0,wx.ALL, 10)
132     self.fieldsFirstRowSizer.Add(self.gameFilePathSizer,0,wx.ALL, 10)
133     self.fieldsFirstRowSizer.Add(self.noIntroGameNameSizer,0,wx.ALL, 10)
134     self.fieldsFirstRowSizer.Add(self.noIntroSystemNameSizer,0,wx.ALL, 10)
135    
136    
137     def MenuData(self):
138     return(("&Tools",
139     ("Import &NoIntro DAT", "Allows for the import of any of the No Intro DAT files.", self.NothingYet),
140     ("Import &TOSEC DAT", "Allows for the import of any of the TOSEC DAT files.", self.NothingYet)),
141     ("&Reports",
142     ("&Duplicates Report","Generates a report detailing duplicates that exist in your collection.", self.NothingYet)),
143     ("&Help",
144     ("&About", "Displays the About Window", self.NothingYet)))
145    
146     def CreateMenuBar(self):
147     menuBar = wx.MenuBar()
148     for eachMenuData in self.MenuData():
149     menuLabel = eachMenuData[0]
150     menuItems = eachMenuData[1:]
151     menuBar.Append(self.CreateMenu(menuItems), menuLabel)
152     self.SetMenuBar(menuBar)
153    
154     def CreateMenu(self, menuData):
155     menu = wx.Menu()
156     for eachLabel, eachStatus, eachHandler in menuData:
157     if not eachLabel:
158     menu.AppendSeparator()
159     continue
160     menuItem = menu.Append(-1, eachLabel, eachStatus)
161     self.Bind(wx.EVT_MENU, eachHandler, menuItem)
162     return menu
163    
164     def OnSystemSelected(self, evt):
165     systemsButtonNamesList = list(self.systemButtonDict.keys())
166     #print(list(self.systemButtonDict.keys()))
167     systemsButtonNamesList.remove(evt.GetEventObject().GetLabelText())
168     #print(evt.GetEventObject().GetLabelText())
169     for i in systemsButtonNamesList:
170     self.systemButtonDict[i].SetValue(False)
171    
172     self.gamesListMatrix = Gromulus_Lib.GetGameListBySystem('snes')
173     gamesList = list(self.gamesListMatrix.keys())
174     gamesList.sort()
175    
176     self.gameSelectionListBox.Clear()
177     self.gameSelectionListBox.AppendItems(gamesList)
178    
179    
180     def OnGameSelected(self, evt):
181     print(self.gameSelectionListBox.GetStringSelection())
182     gameTuple = Gromulus_Lib.GetSingleGameById(self.gamesListMatrix[self.gameSelectionListBox.GetStringSelection()])
183    
184     if gameTuple[0]:
185     self.gameNameTextCtrl.SetValue(gameTuple[0])
186     else:
187     self.gameNameTextCtrl.SetValue("")
188     if gameTuple[1]:
189     self.gameHashTextCtrl.SetValue(gameTuple[1])
190     else:
191     self.gameHashTextCtrl.SetValue("")
192     if gameTuple[2]:
193     self.gameFileNameTextCtrl.SetValue(gameTuple[2])
194     else:
195     self.gameFileNameTextCtrl.SetValue("")
196     if gameTuple[3]:
197     self.gameFilePathTextCtrl.SetValue(gameTuple[3])
198     else:
199     self.gameFilePathTextCtrl.SetValue("")
200     if gameTuple[4]:
201     self.noIntroGameNameTextCtrl.SetValue(gameTuple[4])
202     else:
203     self.noIntroGameNameTextCtrl.SetValue("")
204     if gameTuple[5]:
205     self.noIntroSystemNameTextCtrl.SetValue(gameTuple[5])
206     else:
207     self.noIntroSystemNameTextCtrl.SetValue("")
208    
209     def NothingYet(self, event):
210     diag = wx.MessageDialog(self, "Nothing here yet!", "Disabled...", wx.OK | wx.ICON_INFORMATION)
211     diag.ShowModal()
212     diag.Destroy()
213    
214    
215     class MyApp(wx.App):
216     def OnInit(self):
217     self.frame = MyFrame(None, -1, "Gromulus v1.0")
218     self.frame.Show(True)
219     self.SetTopWindow(self.frame)
220     return True
221    
222    
223     if __name__ == '__main__':
224     app = MyApp(0)
225     app.MainLoop()