Skip to content

Commit

Permalink
#41 seems like beta 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Himura2la committed Jan 7, 2018
1 parent c6366d4 commit 36ca9fd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class Colors:

COUNTDOWN_TEXT_COLOR = (255, 255, 255, 255)

BG_TXT_WIN_CAT_ALTERNATION = FILTERED_GRID


class FileTypes:
video_extensions = {'avi', 'mp4', 'mov', 'wmv', 'mkv'}
Expand Down
11 changes: 6 additions & 5 deletions src/main.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class MainFrame(wx.Frame):
Config.BG_FADE_STOP_DELAYS: 0.03,
Config.BG_FADE_PAUSE_DELAYS: 0.01,
Config.COUNTDOWN_TIME_FMT: u"Ждём Вас в %s ^_^",
Config.C2_DATABASE_PATH: "D:\Fests Local\Past\Yuki no Odori 2016\\2016-fest\C2D\\tulafest\sqlite3_data.db",
Config.C2_DATABASE_PATH: "",
Config.TEXT_WIN_FIELDS: ["Пожелания по сценическому свету (необязательно)"]}

self.logger = Logger(self)
Expand Down Expand Up @@ -418,7 +418,7 @@ class MainFrame(wx.Frame):
def player_status(self, text):
self.status_bar.SetStatusText(text, 2)

def player_status(self, text): # For lambdas
def set_player_status(self, text): # For lambdas
self.status_bar.SetStatusText(text, 2)

@property
Expand All @@ -434,12 +434,13 @@ class MainFrame(wx.Frame):

# -------------------------------------------------- Actions --------------------------------------------------

def on_close(self, e):
def on_close(self, e=None):
self.destroy_proj_win()
self.on_text_win_close()
self.player.stop()
self.vlc_instance.release()
e.Skip()
if e:
e.Skip()

def on_settings(self, e=None):
prev_config = copy.copy(self.config)
Expand Down Expand Up @@ -1129,7 +1130,7 @@ class MainFrame(wx.Frame):

def text_win_show(self, e):
if e.Selection:
if not Config.C2_DATABASE_PATH in self.config or not os.path.exists(self.config[Config.C2_DATABASE_PATH]):
if Config.C2_DATABASE_PATH not in self.config or not os.path.exists(self.config[Config.C2_DATABASE_PATH]):
self.status("No Cosplay2 Database")
return
self.text_win = TextWindow(self, _('Text Data'), self.config[Config.TEXT_WIN_FIELDS])
Expand Down
29 changes: 19 additions & 10 deletions src/text_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import wx.grid
import sqlite3

from constants import Colors


class TextWindow(wx.Frame):
def __init__(self, parent, title, main_fields):
Expand Down Expand Up @@ -32,11 +34,10 @@ def __init__(self, parent, title, main_fields):
main_sizer.Add(label_sizer, 0, wx.EXPAND)

self.grid = wx.grid.Grid(self)
self.columns = ['Section', 'Key', 'Value']
self.grid.CreateGrid(0, len(self.columns))
[self.grid.SetColLabelValue(i, v) for i, v in enumerate(self.columns)]
self.grid.CreateGrid(0, 0)
self.grid.SetColLabelSize(24)
self.grid.HideRowLabels()
self.grid.HideColLabels()
self.grid.SetDefaultRenderer(wx.grid.GridCellAutoWrapStringRenderer())
self.grid.SetDefaultEditor(wx.grid.GridCellAutoWrapStringEditor())
font = self.grid.GetDefaultCellFont()
Expand Down Expand Up @@ -74,7 +75,7 @@ def load_db(self, db_path):

def grid_autosize_cols(self, e=None):
w = self.grid.GetClientSize()[0] - self.grid.GetRowLabelSize()
col_sizes = [self.grid.GetColSize(i) for i in range(self.grid.GetNumberCols())] if e else [1, 1, 2]
col_sizes = [self.grid.GetColSize(i) for i in range(self.grid.GetNumberCols())] if e else [1, 2]
n_cols = self.grid.GetNumberCols()
for col in range(n_cols):
k = w / sum(col_sizes)
Expand Down Expand Up @@ -115,21 +116,29 @@ def load_item(self, list_item):
if not self.show_full_info:
data = list(filter(lambda r: r[2] in self.main_fields, data))

self.grid_set_shape(len(data), 1 if self.show_values_only else 3)
self.grid_set_shape(len(data), 1 if self.show_values_only else 2)

section_i = 1
request_section_id = -1

def set_row(row_number, row_data):
for row_number, row_data in enumerate(data):
prev_section = request_section_id
request_section_id, section_title, title, value, data_type = row_data
if self.show_values_only:
self.grid.SetCellValue(row_number, 0, str(value))
else:
self.grid.SetCellValue(row_number, self.columns.index('Section'), str(section_title))
self.grid.SetCellValue(row_number, self.columns.index('Key'), str(title))
self.grid.SetCellValue(row_number, self.columns.index('Value'), str(value))
self.grid.SetCellValue(row_number, 0, "[%s]\n%s" % (section_title, title))
self.grid.SetCellValue(row_number, 1, str(value))
color = self.grid.GetDefaultCellBackgroundColour() if section_i % 2 \
else Colors.BG_TXT_WIN_CAT_ALTERNATION
self.grid.SetCellBackgroundColour(row_number, 0, color)
self.grid.SetCellBackgroundColour(row_number, 1, color)
if prev_section != request_section_id:
section_i += 1
if self.show_full_info:
self.grid.AutoSizeRow(row_number)
else:
self.grid.SetRowSize(row_number, self.grid.GetClientSize()[1] - 70)
[set_row(i, val) for i, val in enumerate(data)]

self.current_name = "%s: %s %s. %s" % list_item[2:6]
self.label.SetLabel(self.current_name)
Expand Down

0 comments on commit 36ca9fd

Please sign in to comment.