From a78c20f07812297c05b0aa4efb50702de78a006b Mon Sep 17 00:00:00 2001 From: luxick Date: Thu, 1 Mar 2018 19:35:48 +0100 Subject: [PATCH] Add status bar for displaying database connection. --- dsst/dsst_gtk3/gtk_ui.py | 11 +- dsst/dsst_gtk3/resources/glade/window.glade | 1278 ++++++++++--------- dsst/dsst_gtk3/util.py | 1 + 3 files changed, 684 insertions(+), 606 deletions(-) diff --git a/dsst/dsst_gtk3/gtk_ui.py b/dsst/dsst_gtk3/gtk_ui.py index 484d525..eca0c3f 100644 --- a/dsst/dsst_gtk3/gtk_ui.py +++ b/dsst/dsst_gtk3/gtk_ui.py @@ -30,12 +30,19 @@ class GtkUi: self.ui.get_object('main_window').show_all() db_config = config['sql_connections'][0] # Initialize the database - sql.db.init(db_config['db_name'], user=db_config['user'], password=db_config['password']) + sql.db.init(db_config['db_name'], host=db_config['host'], port=db_config['port'], + user=db_config['user'], password=db_config['password']) + # Show database info in status bar + self.set_db_status_label(db_config) # Create database if not exists sql_func.create_tables() self.reload_base_data() + def set_db_status_label(self, db_conf: dict): + self.ui.get_object('connection_label').set_text(f'{db_conf["user"]}@{db_conf["host"]}') + self.ui.get_object('db_label').set_text(f'{db_conf["db_name"]}') + def reload_base_data(self): """Reload function for all base data witch is not dependant on selected season or episode""" # Rebuild all players store @@ -115,7 +122,7 @@ class GtkUi: store.append([victory.id, victory.player.name, victory.enemy.name, victory.info]) # Stat grid - self.ui.get_object('ep_stat_title').set_text('Stats for episode {}\n"{}"'.format(episode.number, episode.name)) + self.ui.get_object('ep_stat_title').set_text('Stats for episode {}\n{}'.format(episode.number, episode.name)) self.ui.get_object('ep_death_count_label').set_text(str(len(episode.deaths))) drink_count = sum(len(death.penalties) for death in episode.deaths) self.ui.get_object('ep_drinks_label').set_text(str(drink_count)) diff --git a/dsst/dsst_gtk3/resources/glade/window.glade b/dsst/dsst_gtk3/resources/glade/window.glade index bf59ea7..9312066 100644 --- a/dsst/dsst_gtk3/resources/glade/window.glade +++ b/dsst/dsst_gtk3/resources/glade/window.glade @@ -12,21 +12,12 @@ - - - - - - - - - - - + False - Edit Victory Event + Manage Players False True + 300 dialog False @@ -39,22 +30,11 @@ False end - - gtk-ok - True - True - True - True - - - True - True - 0 - + - - gtk-cancel + + gtk-ok True True True @@ -90,7 +70,7 @@ False 5 5 - Enemy + Add Player False @@ -99,21 +79,14 @@ - + True - False - enemy_season_store - - - - 0 - - + True + - True + False True - end 1 @@ -125,42 +98,13 @@ - + True False - - - True - False - 5 - 5 - Player - - - False - True - 0 - - - - - True - False - episode_players_store - - - - 1 - - - - - True - True - end - 1 - - + 5 + 5 + All Players + 0 False @@ -169,36 +113,53 @@ - + True - False + True + in - - True - False - Comment - - - False - True - 0 - - - - + True True + True + all_players_store + 0 + + + + + + Name + + + True + + + + 1 + + + + + + + Hex ID + + + True + + + + 2 + + + + - - True - True - end - 1 - - False + True True 2 @@ -213,8 +174,185 @@ - okButtonRename5 - cancelButtonRename1 + okButtonRename2 + + + + + + + + + + + + + + + + + False + Manage Drinks + False + True + 300 + dialog + False + + + False + vertical + 4 + + + False + end + + + + + + gtk-ok + True + True + True + True + + + True + True + 1 + + + + + False + False + 0 + + + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + 5 + 5 + Add Drink + + + False + True + 0 + + + + + True + True + + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + 5 + 5 + All Drinks + 0 + + + False + True + 1 + + + + + True + True + in + + + True + True + True + drink_store + 0 + + + + + + Name + + + True + + + + 1 + + + + + + + Vol. + + + True + + + + 2 + + + + + + + + + True + True + 2 + + + + + True + True + 1 + + + + + + okButtonRename3 @@ -232,11 +370,184 @@ + + False + Manage Enemies For This Season + False + True + 300 + dialog + False + + + False + vertical + 4 + + + False + end + + + + + + gtk-ok + True + True + True + True + + + True + True + 1 + + + + + False + False + 0 + + + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + 5 + 5 + Add Enemy + + + False + True + 0 + + + + + True + True + + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + 5 + 5 + All Enemies + 0 + + + False + True + 1 + + + + + True + True + in + + + True + True + True + enemy_season_store + 0 + + + + + + Name + + + + 0 + + + + + + + + + True + True + 2 + + + + + True + True + 1 + + + + + + okButtonRename1 + + + + + 1000000 1 10 + + + + + + + + + + + + + + + + + + + + + + False False @@ -543,27 +854,203 @@ - - - - - - - - - - - - - - - - - - - - - + + False + Edit Victory Event + False + True + dialog + False + + + False + vertical + 4 + + + False + end + + + gtk-ok + True + True + True + True + + + True + True + 0 + + + + + gtk-cancel + True + True + True + True + + + True + True + 1 + + + + + False + False + 0 + + + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + 5 + 5 + Enemy + + + False + True + 0 + + + + + True + False + enemy_season_store + + + + 0 + + + + + True + True + end + 1 + + + + + False + True + 0 + + + + + True + False + + + True + False + 5 + 5 + Player + + + False + True + 0 + + + + + True + False + episode_players_store + + + + 1 + + + + + True + True + end + 1 + + + + + False + True + 1 + + + + + True + False + + + True + False + Comment + + + False + True + 0 + + + + + True + True + + + True + True + end + 1 + + + + + False + True + 2 + + + + + True + True + 1 + + + + + + okButtonRename5 + cancelButtonRename1 + + + + @@ -589,493 +1076,6 @@ - - False - Manage Drinks - False - True - 300 - dialog - False - - - False - vertical - 4 - - - False - end - - - - - - gtk-ok - True - True - True - True - - - True - True - 1 - - - - - False - False - 0 - - - - - True - False - vertical - 5 - - - True - False - 5 - - - True - False - 5 - 5 - Add Drink - - - False - True - 0 - - - - - True - True - - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - 5 - 5 - All Drinks - 0 - - - False - True - 1 - - - - - True - True - in - - - True - True - True - drink_store - 0 - - - - - - Name - - - True - - - - 1 - - - - - - - Vol. - - - True - - - - 2 - - - - - - - - - True - True - 2 - - - - - True - True - 1 - - - - - - okButtonRename3 - - - - - - - False - Manage Enemies For This Season - False - True - 300 - dialog - False - - - False - vertical - 4 - - - False - end - - - - - - gtk-ok - True - True - True - True - - - True - True - 1 - - - - - False - False - 0 - - - - - True - False - vertical - 5 - - - True - False - 5 - - - True - False - 5 - 5 - Add Enemy - - - False - True - 0 - - - - - True - True - - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - 5 - 5 - All Enemies - 0 - - - False - True - 1 - - - - - True - True - in - - - True - True - True - enemy_season_store - 0 - - - - - - Name - - - - 0 - - - - - - - - - True - True - 2 - - - - - True - True - 1 - - - - - - okButtonRename1 - - - - - - - False - Manage Players - False - True - 300 - dialog - False - - - False - vertical - 4 - - - False - end - - - - - - gtk-ok - True - True - True - True - - - True - True - 1 - - - - - False - False - 0 - - - - - True - False - vertical - 5 - - - True - False - 5 - - - True - False - 5 - 5 - Add Player - - - False - True - 0 - - - - - True - True - - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - 5 - 5 - All Players - 0 - - - False - True - 1 - - - - - True - True - in - - - True - True - True - all_players_store - 0 - - - - - - Name - - - True - - - - 1 - - - - - - - Hex ID - - - True - - - - 2 - - - - - - - - - True - True - 2 - - - - - True - True - 1 - - - - - - okButtonRename2 - - - - - @@ -2464,6 +2464,76 @@ 1 + + + True + False + 5 + 5 + 10 + 10 + 4 + 4 + 5 + + + True + False + Connection: + + + False + True + 2 + + + + + True + False + + + + + + False + True + 3 + + + + + True + False + Database Name: + + + False + True + 4 + + + + + True + False + + + + + + False + True + 5 + + + + + False + True + 2 + + diff --git a/dsst/dsst_gtk3/util.py b/dsst/dsst_gtk3/util.py index 7dda7b8..6a6f567 100644 --- a/dsst/dsst_gtk3/util.py +++ b/dsst/dsst_gtk3/util.py @@ -10,6 +10,7 @@ DEFAULT_CONFIG = { 'auto_connect': False, 'sql_connections': [{ 'host': 'localhost', + 'port': 3306, 'db_name': 'dsst', 'user': 'dsst', 'password': 'dsst'}