| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- """
- 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.
- """
- 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._make_menu_bar()
- # Create the statsusbar
- status = "Status: "
- cursor = conn.execute("""
- SELECT
- player_id,
- player_name,
- player_level,
- ts,
- modified
- FROM info
- """)
- row = cursor.fetchone()
- if row is None:
- status = "No data. Use the update menu."
- else:
- 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 = Tab_List(parent=pnl, id=wx.ID_ANY)
- def _make_menu_bar(self):
- """
- Sets up the application menu.
- """
- update_menu = wx.Menu()
- update_json = update_menu.Append(
- -1,
- "&Update from JSON file\tCtrl-J",
- "Updates the database from a profile JSON file."
- );
- update_swdb = update_menu.Append(
- -1,
- "&Update from SWDB\tCtrl-W",
- "Updates the database from data retrieved from a SWDB instance."
- );
- update_swarfarm = update_menu.Append(
- -1,
- "&Update from Sarfarm\tCtrl-F",
- "Updates the database from data retrieved from Swarfarm."
- );
- update_sqlite = update_menu.Append(
- -1,
- "&Update from a sqlite database\tCtrl-Q",
- "Updates the database from a SWDB sqlite database."
- );
- file_menu = wx.Menu()
- file_about = file_menu.Append(wx.ID_ABOUT)
- file_menu.AppendSeparator()
- file_exit = file_menu.Append(wx.ID_EXIT)
- # Make the menu bar.
- menu_bar = wx.MenuBar()
- menu_bar.Append(file_menu, "&File")
- menu_bar.Append(update_menu, "&Update")
- self.SetMenuBar(menu_bar)
- # Bind menu items
- self.Bind(wx.EVT_MENU, self._close_app, file_exit)
- self.Bind(wx.EVT_MENU, self._show_about, file_about)
- self.Bind(wx.EVT_MENU, self._update_from_json, update_json)
- self.Bind(wx.EVT_MENU, self._update_from_swdb, update_swdb)
- self.Bind(wx.EVT_MENU, self._update_from_swarfarm, update_swarfarm)
- self.Bind(wx.EVT_MENU, self._update_from_sqlite, update_sqlite)
- def _close_app(self, event):
- """
- Closes the app.
- Parameters
- ----------
- event : wx.Event, optional
- The event that triggered the call (default is None).
- """
- self.Close(True)
- def _show_about(self, event):
- """
- Display an About dialog.
- Parameters
- ----------
- event : wx.Event, optional
- The event that triggered the call (default is None).
- """
- wx.MessageBox(
- parent=self,
- message="An about text!",
- caption="RuneOptimizer",
- style=wx.OK | wx.ICON_INFORMATION
- )
- def _update_from_json(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.update_done == True and dlg.update_error == False):
- print("Update succesfull!")
- # TODO: Recalculate status bas message
- def _update_from_swdb(self, event):
- """
- Updates data from a SWDB instance.
- TODO
- Parameters
- ----------
- event : wx.Event, optional
- The event that triggered the call (default is None).
- """
- self._show_unimplemented()
- def _update_from_swarfarm(self, event):
- """
- Updates data from Swarfarm.
- TODO
- Parameters
- ----------
- event : wx.Event, optional
- The event that triggered the call (default is None).
- """
- self._show_unimplemented()
- def _update_from_sqlite(self, event):
- """
- Updates data from a Sqlite file.
- TODO
- Parameters
- ----------
- event : wx.Event, optional
- The event that triggered the call (default is None).
- """
- self._show_unimplemented()
- def _show_unimplemented(self, event=None):
- """
- 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"
- )
|