class WatchDiaryMenu(wx.Frame): def __init__(self, parent, size, userId): if size == 'max': wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=wx.EmptyString, pos=wx.DefaultPosition, size=wx.Size(500, 300), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.Maximize() else: wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=wx.EmptyString, pos=wx.DefaultPosition, size=wx.Size(size), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.SetSizeHints(wx.DefaultSize, wx.DefaultSize) bSizer12 = wx.BoxSizer(wx.VERTICAL) self.go_back_button = wx.Button(self, wx.ID_ANY, u"뒤로가기", wx.DefaultPosition, wx.DefaultSize, 0) bSizer12.Add(self.go_back_button, 0, wx.ALL, 5) self.m_panel81 = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) gbSizer31 = wx.GridBagSizer(0, 0) gbSizer31.SetFlexibleDirection(wx.BOTH) gbSizer31.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) self.range_text = wx.StaticText(self.m_panel81, wx.ID_ANY, u"범위", wx.DefaultPosition, wx.DefaultSize, 0) self.range_text.Wrap(-1) gbSizer31.Add(self.range_text, wx.GBPosition(0, 0), wx.GBSpan(1, 1), wx.ALL, 5) range_choiceChoices = [u"전체", u"선택"] self.range_choice = wx.Choice(self.m_panel81, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, range_choiceChoices, 0) self.range_choice.SetSelection(0) gbSizer31.Add(self.range_choice, wx.GBPosition(0, 1), wx.GBSpan(1, 1), wx.ALL, 5) self.feel_text = wx.StaticText(self.m_panel81, wx.ID_ANY, u"기분", wx.DefaultPosition, wx.DefaultSize, 0) self.feel_text.Wrap(-1) gbSizer31.Add(self.feel_text, wx.GBPosition(0, 2), wx.GBSpan(1, 1), wx.ALL, 5) feel_range_choiceChoices = [u"전체", u"선택"] self.feel_range_choice = wx.Choice(self.m_panel81, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, feel_range_choiceChoices, 0) self.feel_range_choice.SetSelection(0) gbSizer31.Add(self.feel_range_choice, wx.GBPosition(0, 3), wx.GBSpan(1, 1), wx.ALL, 5) self.thoughts_count_text = wx.StaticText(self.m_panel81, wx.ID_ANY, u"생각개수", wx.DefaultPosition, wx.DefaultSize, 0) self.thoughts_count_text.Wrap(-1) gbSizer31.Add(self.thoughts_count_text, wx.GBPosition(0, 4), wx.GBSpan(1, 1), wx.ALL, 5) feel_range_choice1Choices = [u"전체", u"선택"] self.feel_range_choice1 = wx.Choice(self.m_panel81, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, feel_range_choice1Choices, 0) self.feel_range_choice1.SetSelection(0) gbSizer31.Add(self.feel_range_choice1, wx.GBPosition(0, 5), wx.GBSpan(1, 1), wx.ALL, 5) self.search_button = wx.Button(self.m_panel81, wx.ID_ANY, u"검색", wx.DefaultPosition, wx.DefaultSize, 0) gbSizer31.Add(self.search_button, wx.GBPosition(0, 6), wx.GBSpan(1, 1), wx.ALL, 5) self.m_panel81.SetSizer(gbSizer31) self.m_panel81.Layout() gbSizer31.Fit(self.m_panel81) bSizer12.Add(self.m_panel81, 0, wx.ALL | wx.EXPAND, 5) self.m_scrolledWindow2 = wx.ScrolledWindow(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL | wx.VSCROLL) self.m_scrolledWindow2.SetScrollRate(5, 5) bSizer22 = wx.BoxSizer(wx.VERTICAL) self.starPng = wx.Image('star.png', wx.BITMAP_TYPE_ANY) frameSizeX, frameSizeY = self.GetSize() self.starPng.Rescale(16, 16) self.starPng = self.starPng.ConvertToBitmap() del frameSizeX, frameSizeY self.DbManager = DbManager() self.userId = userId diary = self.DbManager.findDiaryWithCondition(startDate='1970-01-01', finishDate='2099-01-01', startFeelRange=1, finishFeelRange=5, thoughtsStartRange=0, thoughtsFinishRange=100, userId=self.userId) for i in range(len(diary)): date = diary[i][0] time = diary[i][1] todayFeel = diary[i][2] todayThoughtsCount = diary[i][3] diaryPanel = self.makeDiaryPanel(date, time, todayFeel, todayThoughtsCount, len(diary), self.m_scrolledWindow2) bSizer22.Add(diaryPanel, 1, wx.EXPAND | wx.ALL, 5) self.m_scrolledWindow2.SetSizer(bSizer22) self.m_scrolledWindow2.Layout() bSizer22.Fit(self.m_scrolledWindow2) bSizer12.Add(self.m_scrolledWindow2, 1, wx.EXPAND | wx.ALL, 5) self.SetSizer(bSizer12) self.Layout() self.Centre(wx.BOTH) # Connect Events self.Bind(wx.EVT_CLOSE, self.onClose) self.range_choice.Bind(wx.EVT_CHOICE, self.rangeChoiced) self.feel_range_choice.Bind(wx.EVT_CHOICE, self.feelRangeChoiced) self.feel_range_choice1.Bind(wx.EVT_CHOICE, self.thoughtsRangeChoiced) self.search_button.Bind(wx.EVT_BUTTON, self.searchButtonClicked) self.go_back_button.Bind(wx.EVT_BUTTON, self.goBackButtonClicked) def __del__(self): pass def makeDiaryPanel(self, date, time, star, thoughtsCount, diaryCount, m_scrolledWindow2): m_panel8 = wx.Panel(m_scrolledWindow2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) gbSizer3 = wx.GridBagSizer(0, 0) gbSizer3.SetFlexibleDirection(wx.BOTH) gbSizer3.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) date_text = wx.StaticText(m_panel8, wx.ID_ANY, u'{0}'.format(date), wx.DefaultPosition, wx.DefaultSize, 0) date_text.Wrap(-1) gbSizer3.Add(date_text, wx.GBPosition(0, 0), wx.GBSpan(1, 1), wx.ALL, 5) time_text = wx.StaticText(m_panel8, wx.ID_ANY, u"{0}".format(time), wx.DefaultPosition, wx.DefaultSize, 0) time_text.Wrap(-1) gbSizer3.Add(time_text, wx.GBPosition(0, 2), wx.GBSpan(1, 1), wx.ALL, 5) thoughts_count = wx.StaticText(m_panel8, wx.ID_ANY, u"{0}".format(thoughtsCount), wx.DefaultPosition, wx.DefaultSize, 0) thoughts_count.Wrap(-1) gbSizer3.Add(thoughts_count, wx.GBPosition(0, 3), wx.GBSpan(1, 1), wx.ALL, 5) diary_show_button = wx.Button(m_panel8, wx.ID_ANY, u"일기보기", wx.DefaultPosition, wx.DefaultSize, 0) gbSizer3.Add(diary_show_button, wx.GBPosition(0, 5), wx.GBSpan(1, 1), wx.ALL, 5) m_panel18 = wx.Panel(m_panel8, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) gbSizer4 = wx.GridBagSizer(0, 0) gbSizer4.SetFlexibleDirection(wx.BOTH) gbSizer4.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) for i in range(int(star)): star = wx.StaticBitmap(m_panel18, wx.ID_ANY, self.starPng, wx.DefaultPosition, wx.DefaultSize, 0) gbSizer4.Add(star, wx.GBPosition(0, i), wx.GBSpan(1, 1), wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5) m_panel18.SetSizer(gbSizer4) m_panel18.Layout() gbSizer4.Fit(m_panel18) gbSizer3.Add(m_panel18, wx.GBPosition(0, 4), wx.GBSpan(1, 1), wx.EXPAND | wx.ALL, 5) m_panel8.SetSizer(gbSizer3) m_panel8.Layout() gbSizer3.Fit(m_panel8) diary_show_button.Bind( wx.EVT_BUTTON, lambda event: self.diaryShowButtonClicked(event, date)) return m_panel8 # Virtual event handlers, overide them in your derived class def onClose(self, event): self.DbManager.closeDb() self.Destroy() sys.exit() def rangeChoiced(self, event): event.Skip() def feelRangeChoiced(self, event): event.Skip() def thoughtsRangeChoiced(self, event): event.Skip() def searchButtonClicked(self, event): event.Skip() def goBackButtonClicked(self, event): if self.IsMaximized(): frameSize = 'max' else: frameSize = self.GetSize() frame1 = DiaryMainMenu(parent=None, size=frameSize, userId=self.userId) frame1.Show(True) self.Show(False) def diaryShowButtonClicked(self, event, date): watchDiary = WatchDiary() diaryContent = watchDiary.readCorrectDiaryTxt(date) todayThoughtsContent = watchDiary.readCorrectTodayThoughtsTxt(date) diaryInfo = self.DbManager.readDiaryInfo(date, self.userId) if self.IsMaximized(): frameSize = 'max' else: frameSize = self.GetSize() if date == str(arrow.now().date()): frame1 = WriteDiaryMenu(parent=None, mode='w', size=frameSize, userId=self.userId, diaryContent=diaryContent, todayFeel=diaryInfo[2], todayThoughts=todayThoughtsContent) else: frame1 = WriteDiaryMenu(parent=None, mode='r', size=frameSize, userId=self.userId, diaryContent=diaryContent, todayFeel=diaryInfo[2], todayThoughts=todayThoughtsContent) frame1.Show(True) self.Show(False)