From dfd0d77873c0ad217d76e11df57e9afb92a3a0bd Mon Sep 17 00:00:00 2001 From: danamir Date: Mon, 24 Dec 2018 16:39:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=90=D0=B2=D1=82=D0=BE=D0=BC=D0=B0=D1=82?= =?UTF-8?q?=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=BE=D0=B5=20=D0=BE=D0=BF=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=83?= =?UTF-8?q?=D1=82=D0=B8=20=D0=BA=20=D0=B1=D0=B0=D0=B7=D0=B5=20=D0=B4=D0=B0?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D1=85=20=D0=97=D0=B0=D0=BA=D0=BE=D0=BD=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=B4=201=D0=BC=20=D0=BE=D0=BA=D0=BD=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller.py | 35 ++++++++++++++-------------------- db/models.py | 6 ++++-- db/odd.db | Bin 16384 -> 16384 bytes gui/SecondPage.py | 6 ++++++ main.py | 47 ++++++++++++++++++++++++++++++++-------------- run.sh | 12 ++++++++++++ 6 files changed, 69 insertions(+), 37 deletions(-) create mode 100755 run.sh diff --git a/controller.py b/controller.py index 4d27ad8..1b986c0 100644 --- a/controller.py +++ b/controller.py @@ -1,5 +1,5 @@ import os -import tkinter as tk +import sys import wx def hex_to_rgb(value): @@ -14,7 +14,7 @@ def setBacgroundColor(): """ hex_color = "#DBF0B2" color =hex_to_rgb(hex_color) - + return color def setBckgroundButtonColor(): @@ -27,25 +27,18 @@ def setBckgroundButtonColor(): color = hex_to_rgb(hex_color) return color - -def getFullPath(file): - put = os.getcwd() - path = str(put) + '\\' + file - return path -def setFrameSize(): - """ - :parameter sh,sw - ширина и высота экрана, на котором - запускается программа - :return: w,h - размеры фрейма для отрисовки gui - """ - root = tk.Tk() - sw = root.winfo_screenwidth() - sh = root.winfo_screenheight() - w,h = int(0.75 * sw), int(0.75 * sh) - - if w < 800 and h < 600: - w, h = 800, 600 - +def getSizeH(): + app = wx.App(False) + sw, sh = wx.GetDisplaySize() + w = 0.75 * sw + h = 0.75 * sh + app.Destroy() return w, h + + + + + + diff --git a/db/models.py b/db/models.py index c9169e7..f329782 100644 --- a/db/models.py +++ b/db/models.py @@ -2,9 +2,11 @@ from sqlalchemy import Column, Integer, String, Float from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker +import os -path = "C:\\Users\\danamir\\PycharmProjects\\odd-perekrestok\\db\\odd.db" -engine = create_engine("sqlite:///C:\\Users\\danamir\\PycharmProjects\\odd-perekrestok\\db\\odd.db", echo=True) +path_db = os.path.abspath("db/odd.db") +path = "sqlite:////" + path_db +engine = create_engine(path, echo=True) Session = sessionmaker(bind=engine) Base = declarative_base(engine) meta = Base.metadata diff --git a/db/odd.db b/db/odd.db index e33735fafba39c30c4ca360f8f6854328a9dce08..7c9600627116962299c3d2274ec93ac1333423ec 100644 GIT binary patch delta 66 zcmZo@U~Fh$oFL7}I#I@%m6bvF8TZDN1^gUL{LdNqzw$rdEGTfBUy_H3l|fvP)6h`C S5C}LKSs8@+IYFF70tx^)R}QKG delta 31 ncmZo@U~Fh$oFL7}JW5<31^k;?6#mFBG7ta&j-3fm diff --git a/gui/SecondPage.py b/gui/SecondPage.py index ac064ed..66cbef7 100644 --- a/gui/SecondPage.py +++ b/gui/SecondPage.py @@ -1,6 +1,7 @@ import wx import random import os +import controller class SeconPageFrame(wx.Frame): @@ -37,6 +38,11 @@ class SeconPageFrame(wx.Frame): # begin wxGlade: SeconPageFrame.__set_properties self.SetTitle("Расчет цикла светофорного регулирования") + self.color = controller.setBacgroundColor() + self.SetBackgroundColour(self.color) + self.btnColor = controller.setBckgroundButtonColor() + self.btn2.SetBackgroundColour(self.btnColor) + def __do_layout(self): # begin wxGlade: SeconPageFrame.__do_layout sizer_1 = wx.BoxSizer(wx.VERTICAL) diff --git a/main.py b/main.py index 03adc06..16c03f9 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,9 @@ from db.models import Student from sqlalchemy import exists from db.models import Session from gui import SecondPage +import tkinter as tk +import sys + class MyFrame(wx.Frame): def __init__(self, *args, **kwds): @@ -19,10 +22,13 @@ class MyFrame(wx.Frame): 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.size = self.SetSize(600, 600) self.__set_properties() self.__do_layout() + self.__binds() + + # end wxGlade def __set_properties(self): @@ -31,19 +37,17 @@ 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.color = controller.setBacgroundColor() - self.panel_1.SetBackgroundColour(self.color) - - self.button_1.SetBackgroundColour(controller.setBckgroundButtonColor()) - - + self.color = controller.setBacgroundColor() + self.SetBackgroundColour(self.color) + self.btnColor = controller.setBckgroundButtonColor() + self.btn2.SetBackgroundColour(self.btnColor) + + + + + + def __do_layout(self): # begin wxGlade: MyFrame.__do_layout sizer_1 = wx.BoxSizer(wx.VERTICAL) @@ -85,11 +89,22 @@ class MyFrame(wx.Frame): self.Layout() # end wxGlade + def __binds(self): + self.button_1.Bind(wx.EVT_BUTTON, self.go_page2) + + def getSize(self): + app = wx.App(False) + sw, sh = wx.GetDisplaySize() + self.w = 0.75 * sw + self.h = 0.75 * sh + return self.w, self.h + def empty_pole(self): dlg = wx.MessageDialog(self, 'Не все поля заполнены. Заполните все поля перед продолжением', 'Ошибка', wx.OK) val = dlg.ShowModal() if val == wx.ID_OK: dlg.Destroy() + def go_page2(self, event): name = self.inpt_name.GetValue() @@ -123,8 +138,8 @@ class MyFrame(wx.Frame): new_session.commit() - self.frame.Destroy() SecondPage.SecondPage.OnInit(SecondPage) + self.Destroy() # todo Перенести весь функционал из main.py @@ -138,5 +153,9 @@ class MyApp(wx.App): # end of class MyApp if __name__ == "__main__": + app = MyApp(0) + import wx.lib.inspection + + wx.lib.inspection.InspectionTool().Show() app.MainLoop() diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..e1ce366 --- /dev/null +++ b/run.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# what real Python executable to use +PYVER=3.7 +PYTHON=/Library/Frameworks/Python.framework/Versions/$PYVER/bin/python$PYVER + +# find the root of the virtualenv, it should be the parent of the dir this script is in +ENV=`$PYTHON -c "import os; print os.path.abspath(os.path.join(os.path.dirname(\"$0\"), '..'))"` + +# now run Python with the virtualenv set as Python's HOME +export PYTHONHOME=$ENV +exec $PYTHON "$@" \ No newline at end of file