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 e33735f..7c96006 100644 Binary files a/db/odd.db and b/db/odd.db differ 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