From ca1f94510146815c9e57c37b3caf45332ba10bc0 Mon Sep 17 00:00:00 2001 From: danamir Date: Wed, 12 Dec 2018 09:46:16 +0300 Subject: [PATCH] fixing bugs --- controller.py | 22 +++++++++++++++------- main.py | 16 ++++++++++------ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/controller.py b/controller.py index 5b1723e..4d27ad8 100644 --- a/controller.py +++ b/controller.py @@ -2,12 +2,19 @@ import os import tkinter as tk import wx +def hex_to_rgb(value): + value = value.lstrip('#') + lv = len(value) + return tuple(int(value[i:i + lv // 3], 16) for i in range(0, lv, lv // 3)) + def setBacgroundColor(): """ Устанавливает цвет панели для приложения :return: """ - color = "white" + hex_color = "#DBF0B2" + color =hex_to_rgb(hex_color) + return color def setBckgroundButtonColor(): @@ -16,17 +23,18 @@ def setBckgroundButtonColor(): Устанавливает цвет кнопок :return: """ - wx.lib.colourdb.updateColourDB() - color = wx.NamedColour("light coral") - return color + hex_color = "#F8B8B8" + color = hex_to_rgb(hex_color) + return color + def getFullPath(file): put = os.getcwd() path = str(put) + '\\' + file return path -def setSize(): +def setFrameSize(): """ :parameter sh,sw - ширина и высота экрана, на котором запускается программа @@ -35,9 +43,9 @@ def setSize(): root = tk.Tk() sw = root.winfo_screenwidth() sh = root.winfo_screenheight() - w = int(0.75 * sw) - h = int(0.75 * sh) + w,h = int(0.75 * sw), int(0.75 * sh) if w < 800 and h < 600: w, h = 800, 600 + return w, h diff --git a/main.py b/main.py index 91616c5..03adc06 100644 --- a/main.py +++ b/main.py @@ -12,13 +12,14 @@ class MyFrame(wx.Frame): # begin wxGlade: MyFrame.__init__ kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) - self.panel_1 = wx.Panel(self, wx.ID_ANY) + self.panel_1 = wx.Panel(self, wx.ID_ANY, size=(100, 100)) self.inpt_name = wx.TextCtrl(self.panel_1, wx.ID_ANY, "") self.inpt_familia = wx.TextCtrl(self.panel_1, wx.ID_ANY, "") self.inpt_group = wx.TextCtrl(self.panel_1, wx.ID_ANY, "") self.inpt_zachetka = wx.TextCtrl(self.panel_1, wx.ID_ANY, "") self.btn2 = wx.Button(self.panel_1, wx.ID_ANY, u"\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438") self.button_1 = wx.Button(self.panel_1, wx.ID_ANY, u"\u0414\u0430\u043b\u0435\u0435") + self.__set_properties() self.__do_layout() @@ -30,16 +31,19 @@ class MyFrame(wx.Frame): self.inpt_name.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) self.inpt_familia.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) self.inpt_zachetka.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) + + self.framesize = controller.setFrameSize() + print(self.framesize) self.btn2.SetMinSize((100, 50)) self.button_1.SetMinSize((100, 50)) - self.frameSize = controller.setSize() - self.SetSize(self.frameSize) - self.SetMinSize((800, 600)) + self.color = controller.setBacgroundColor() self.panel_1.SetBackgroundColour(self.color) + + self.button_1.SetBackgroundColour(controller.setBckgroundButtonColor()) + - # end wxGlade - + def __do_layout(self): # begin wxGlade: MyFrame.__do_layout sizer_1 = wx.BoxSizer(wx.VERTICAL)