| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- """
- This file is part of RuneOptimizer.
- RuneOptimizer is free software: you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
- RuneOptimizer is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
- You should have received a copy of the GNU General Public License along with
- RuneOptimizer. If not, see <https://www.gnu.org/licenses/>.
- """
- class RuneOptimizerFrame(wx.Frame):
- """
- The main application window.
- Methods
- -------
- makeMenuBar(event)
- Creates the app menu bar.
- closeApp(event)
- Closes the app.
- showAbout(event)
- Display an About dialog.
- updateFromJson(event)
- Shows a dialog to update data from a JSON file.
- updateFromSwdb(event)
- Updates data from a SWDB instance.
- updateFromSwarfarm(event)
- Updates data from Swarfarm.
- updateFromSqlite(event)
- Updates data from a SQLite file.
- showUnimplemented(parent, event)
- Displays a message for unimplemented features.
- """
- def __init__(self, *args, **kw):
- """
- Initializes the class.
- Sets upt all the widgets.
- """
- global conn
- super(RuneOptimizerFrame, self).__init__(*args, **kw)
- # Create and configure the menue
- pnl = wx.Panel(self)
- self.makeMenuBar()
- # Create the statsusbar
- status = "Status: "
- cursor = conn.execute("""
- SELECT
- player_id,
- player_name,
- player_level,
- ts,
- modified
- FROM info
- """)
- row = cursor.fetchone()
- status = row[1] + ", Lv" + str(row[2]) + " (ID #" +str(row[0]) + ")."
- status += " Last updated " + str(row[3])
- if (row[4] == 1):
- status += ". Modifications applied since."
- else:
- status += ". No modifications applied since."
- self.CreateStatusBar()
- self.SetStatusText(status)
- # Create tabs
- tabs = TabList(parent=pnl, id=wx.ID_ANY)
- def makeMenuBar(self):
- """
- Sets up the application menu.
- """
- updateMenu = wx.Menu()
- updateJson = updateMenu.Append(
- -1,
- "&Update from JSON file\tCtrl-J",
- "Updates the database from a profile JSON file."
- );
- updateSwdb = updateMenu.Append(
- -1,
- "&Update from SWDB\tCtrl-W",
- "Updates the database from data retrieved from a SWDB instance."
- );
- updateSwarfarm = updateMenu.Append(
- -1,
- "&Update from Sarfarm\tCtrl-F",
- "Updates the database from data retrieved from Swarfarm."
- );
- updateSqlite = updateMenu.Append(
- -1,
- "&Update from a sqlite database\tCtrl-Q",
- "Updates the database from a SWDB sqlite database."
- );
- fileMenu = wx.Menu()
- aboutItem = fileMenu.Append(wx.ID_ABOUT)
- fileMenu.AppendSeparator()
- exitItem = fileMenu.Append(wx.ID_EXIT)
- # Make the menu bar.
- menuBar = wx.MenuBar()
- menuBar.Append(fileMenu, "&File")
- menuBar.Append(updateMenu, "&Update")
- self.SetMenuBar(menuBar)
- # Bind menu items
- self.Bind(wx.EVT_MENU, self.closeApp, exitItem)
- self.Bind(wx.EVT_MENU, self.showAbout, aboutItem)
- self.Bind(wx.EVT_MENU, self.updateFromJson, updateJson)
- self.Bind(wx.EVT_MENU, self.updateFromSwdb, updateSwdb)
- self.Bind(wx.EVT_MENU, self.updateFromSwarfarm, updateSwarfarm)
- self.Bind(wx.EVT_MENU, self.updateFromSqlite, updateSqlite)
- def closeApp(self, event):
- """
- Closes the app.
- Parameters
- ----------
- event : wx.Event, optional
- The event that triggered the call (default is None).
- """
- self.Close(True)
- def showAbout(self, event):
- """
- Display an About dialog.
- Parameters
- ----------
- event : wx.Event, optional
- The event that triggered the call (default is None).
- """
- wx.MessageBox("RuneOptimizerAbout", wx.OK | wx.ICON_INFORMATION)
- def updateFromJson(self, event = None):
- """
- Shows a dialog to update data from a JSON file.
- Parameters
- ----------
- event : wx.Event, optional
- The event that triggered the call (default is None).
- """
- with DialogUpdateJson(self) as dlg:
- if dlg.ShowModal() == wx.ID_OK:
- # do something here
- if (dlg.updateDone == True and dlg.updateError == False):
- print("Update succesfull!")
- else:
- print('Update cancelled')
- def updateFromSwdb(self, event):
- """
- Updates data from a SWDB instance.
- TODO
- Parameters
- ----------
- event : wx.Event, optional
- The event that triggered the call (default is None).
- """
- self.showUnimplemented()
- def updateFromSwarfarm(self, event):
- """
- Updates data from Swarfarm.
- TODO
- Parameters
- ----------
- event : wx.Event, optional
- The event that triggered the call (default is None).
- """
- self.showUnimplemented()
- def updateFromSqlite(self, event):
- """
- Updates data from a Sqlite file.
- TODO
- Parameters
- ----------
- event : wx.Event, optional
- The event that triggered the call (default is None).
- """
- self.showUnimplemented()
- def showUnimplemented(self, event):
- """
- Displays a message for unimplemented features.
- Parameters
- ----------
- event : wx.Event, optional
- The event that triggered the call (default is None).
- """
- wx.MessageBox(
- parent=self,
- message="This functionality is not yet implemented",
- caption="Unimplemented"
- )
|