From 12158833ac9897ebfc73e4a30bac77e4ea2efc4d Mon Sep 17 00:00:00 2001 From: Quickinline Date: Tue, 16 Mar 2021 16:45:03 +0100 Subject: [PATCH] project setup --- .vscode/launch.json | 15 +++ .vscode/settings.json | 5 + projetsysteme/__init__.py | 5 + .../__pycache__/__init__.cpython-38.pyc | Bin 0 -> 240 bytes .../__pycache__/components.cpython-38.pyc | Bin 0 -> 1680 bytes projetsysteme/__pycache__/main.cpython-38.pyc | Bin 0 -> 532 bytes .../__pycache__/settings.cpython-38.pyc | Bin 0 -> 231 bytes .../__pycache__/views.cpython-38.pyc | Bin 0 -> 1368 bytes projetsysteme/components.py | 38 ++++++ projetsysteme/dna.py | 12 ++ projetsysteme/main.py | 20 +++ projetsysteme/settings.py | 6 + projetsysteme/test.py | 123 ++++++++++++++++++ projetsysteme/views.py | 49 +++++++ start.py | 10 ++ test.txt | 0 16 files changed, 283 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 projetsysteme/__init__.py create mode 100644 projetsysteme/__pycache__/__init__.cpython-38.pyc create mode 100644 projetsysteme/__pycache__/components.cpython-38.pyc create mode 100644 projetsysteme/__pycache__/main.cpython-38.pyc create mode 100644 projetsysteme/__pycache__/settings.cpython-38.pyc create mode 100644 projetsysteme/__pycache__/views.cpython-38.pyc create mode 100644 projetsysteme/components.py create mode 100644 projetsysteme/dna.py create mode 100644 projetsysteme/main.py create mode 100644 projetsysteme/settings.py create mode 100644 projetsysteme/test.py create mode 100644 projetsysteme/views.py create mode 100644 start.py create mode 100644 test.txt diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..6603608 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Current File", + "type": "python", + "request": "launch", + "program": "start.py", + "console": "integratedTerminal" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..df63951 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "python.linting.pylintEnabled": false, + "python.linting.enabled": true, + "python.linting.banditEnabled": true +} \ No newline at end of file diff --git a/projetsysteme/__init__.py b/projetsysteme/__init__.py new file mode 100644 index 0000000..967bff3 --- /dev/null +++ b/projetsysteme/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- + +"""This module provides the projetsysteme package.""" + +__version__ = "0.1.0" \ No newline at end of file diff --git a/projetsysteme/__pycache__/__init__.cpython-38.pyc b/projetsysteme/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7d1b84b9f5530ddd33fd119e9fd676f9326fe00b GIT binary patch literal 240 zcmYjLOA5j;5KU7>@w4#+-MVS&Uc?iKpl;lZp&4vy+mt2>?TtK#x9HYexN`h~59ZCh z8F+7YjT(Gj*6aZIN`IPde$5JFFMk@E-FTeGFZD+E?hQGnBmRO=xh$AvxojZ@%I0!(l*Roc(k7XX+60FDknO z_Q(^M3I!*eW+bPK<`%PZo7uU;oZMwDB|i~var=yLThKQ)^FVjF3%V;@(0klFB4O_W zypYgsKAQd-r^WNM;N=pOpAX7czr?Gu(oJvrJmoW?8-My+S!M^Zg!98n%?~QA%OXJs zy8{Enp~fHtVU!bQasMqjp(da{v)e$J!#&p6|Lu_Tzsc6hKrqo**{Um!5I*S4l0o!Z%0H9e=47~QR1 z&@I$!dt=wm<;v|=4hOK$EpzU0036q7Ta(DG$;PY6X?qvG;LAokP5?u9A}Rd)1;%z^ zRy|mSJ&79IgbVrVU%y~->7QpV2mO>|UHcS8u8D~qw9Cj0qp0+#f<MjUEJ@^F{&VUAV zKnIo&a{bkN)%eiIHO^timv#9T6jK)qFr-}t=#S)&(QCW5wm81LZIGms(3UP(umDi% zdPm-ZjnFaavwkj$>KQOdF;_!xsm4h`dp}J?wln_>tQF>n=>^oM>rXyRr@I?M06k=W z5$7U`njnhul2;k72T}C0inI2_5LO~+@>3Aauxp4!WLXsLL^HrEh`dBjAR!de)~6%K zzh(9kP_GTVghSl}v3(89TL1(-^O#`|?qxytZ3p_niT`eVVHr+o z4Mq4H+kk8=ZW_cuZ%x(@kK^RUOqNx_A0%Z~%12+q+@ fhJg~xWC~==cKlyP-uU0Q?0Af@oAB>hH}C%s94?2f literal 0 HcmV?d00001 diff --git a/projetsysteme/__pycache__/main.cpython-38.pyc b/projetsysteme/__pycache__/main.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b53387564a05a81c1ba57b6fa33a6d6f8d507119 GIT binary patch literal 532 zcmYjOyH3L}6uowwG=d^_rmR7tVPQZ*2-F=Y40PTrl#|qM`U|U%VfHcgHi7{|?&%YG1mirxBbk#0TLM9L z;m%>Mi%2!-Wx`I=iDOZwaa_At^UbsA!0hz~=30q6X>_ZYyJICMx>egAYbC9~Iv#EOgP%`1 Nw5HltjQX^T;~N#fg8Bde literal 0 HcmV?d00001 diff --git a/projetsysteme/__pycache__/settings.cpython-38.pyc b/projetsysteme/__pycache__/settings.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1eb7ed9f9ad27025c0d40ef4236a7e66555d9704 GIT binary patch literal 231 zcmWIL<>g`kg8qpC2~I%zF^Gc<7=auIATH(s5-AK(3@MCJj44dP44TYU(pBS0Z`9%r=m4PJ+0Y&*)smUc=rTjqkU`~lbaAk4H;T5^5ews|T*yH0<@{{A^Z}F68 z=B4D9$CqT525n5GMCuvLs&)0g@ucc7amJRe%&p5IX_x3|tHgwsQa*hFC{AWbSU#L7@ zU?bnbw$I^^gb_()plKDbpbA-7MJ%F3hBDG|m9WIiu}-UuWz~QUD0xO?BGX$UQFzJ+%kpK}{kAy>j_k-Cy(g4x$z9;Wd+MbKEs{dmpdFpor7MLl zTV-Zv)3}T6YNd7`z(#;MMCnaz;$t0az1N38;APY36JZR3=0AT~${Xbj_7OvdFV$Peo_eY;V5F{v z>8D{DnKAl|?PDt&VnMw}7i%0S^AWi9$5WI>aC`#WcP9yfPhd2n2~GYbdnmhA;O=+e|LDknY%A%a~KE2$$FqX*gb?9BERM@m;V0 literal 0 HcmV?d00001 diff --git a/projetsysteme/components.py b/projetsysteme/components.py new file mode 100644 index 0000000..ba5324f --- /dev/null +++ b/projetsysteme/components.py @@ -0,0 +1,38 @@ +from PyQt5.QtWidgets import QMainWindow, QHBoxLayout, QWidget, QToolBar, QPushButton + +class AbstractWindow(QMainWindow): + def __init__(self, parent=None): + """Initializer.""" + super().__init__() + + def setupSidebarLayout(self,sidebarLayout, mainLayout): + layout = QHBoxLayout() + left = QWidget() + left.setLayout(sidebarLayout) + + right = QWidget() + right.setLayout(mainLayout) + + layout.addWidget(left) + layout.addWidget(right) + layout.setStretch(0, 3) + layout.setStretch(1, 7) + + self.centralwidget = QWidget() + self.setCentralWidget(self.centralwidget) + self.centralwidget.setLayout(layout) + + + # automatizing setting the ToolBar for the app + def setToolBar(self, menuItems): + tools = QToolBar() + self.addToolBar(tools) + for item in menuItems : + tools.addWidget(item) + + +class QPrimaryButton(QPushButton): + def __init__(self, *args, **kwargs): + super().__init__(*args,**kwargs) + self.setStyleSheet("background-color: indigo;color:white;font-weight:bold;") + diff --git a/projetsysteme/dna.py b/projetsysteme/dna.py new file mode 100644 index 0000000..3d7fe57 --- /dev/null +++ b/projetsysteme/dna.py @@ -0,0 +1,12 @@ + + +class DNA(): + chain= "" + + # read from fasta file + def __init__(self, path: str): + pass + + # generate DNA Sequence from length + def __init__(slef, length: int): + pass diff --git a/projetsysteme/main.py b/projetsysteme/main.py new file mode 100644 index 0000000..33d96ae --- /dev/null +++ b/projetsysteme/main.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# rpcontacts/main.py + +"""This module provides RP Contacts application.""" + +import sys + +from PyQt5.QtWidgets import QApplication + +from .views import Window + +def main(): + """RP Contacts main function.""" + # Create the application + app = QApplication(sys.argv) + # Create the main window + win = Window() + win.show() + # Run the event loop + sys.exit(app.exec()) \ No newline at end of file diff --git a/projetsysteme/settings.py b/projetsysteme/settings.py new file mode 100644 index 0000000..b58d0f9 --- /dev/null +++ b/projetsysteme/settings.py @@ -0,0 +1,6 @@ +""" +Settings for PyQt Project +""" + + +window_title="Projet Système" \ No newline at end of file diff --git a/projetsysteme/test.py b/projetsysteme/test.py new file mode 100644 index 0000000..1bec7a6 --- /dev/null +++ b/projetsysteme/test.py @@ -0,0 +1,123 @@ +from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QBoxLayout, QVBoxLayout, QHBoxLayout, QWidget, QTabWidget, QLabel +import sys + + +class Window(QMainWindow): + def __init__(self): + super().__init__() + + # set the title of main window + self.setWindowTitle('Sidebar layout - www.luochang.ink') + + # set the size of window + self.Width = 800 + self.height = int(0.618 * self.Width) + self.resize(self.Width, self.height) + + # add all widgets + self.btn_1 = QPushButton('1', self) + self.btn_2 = QPushButton('2', self) + self.btn_3 = QPushButton('3', self) + self.btn_4 = QPushButton('4', self) + + self.btn_1.clicked.connect(self.button1) + self.btn_2.clicked.connect(self.button2) + self.btn_3.clicked.connect(self.button3) + self.btn_4.clicked.connect(self.button4) + + # add tabs + self.tab1 = self.ui1() + self.tab2 = self.ui2() + self.tab3 = self.ui3() + self.tab4 = self.ui4() + + self.initUI() + + def initUI(self): + left_layout = QVBoxLayout() + left_layout.addWidget(self.btn_1) + left_layout.addWidget(self.btn_2) + left_layout.addWidget(self.btn_3) + left_layout.addWidget(self.btn_4) + left_layout.addStretch(5) + left_layout.setSpacing(20) + left_widget = QWidget() + left_widget.setLayout(left_layout) + + self.right_widget = QTabWidget() + self.right_widget.tabBar().setObjectName("mainTab") + + self.right_widget.addTab(self.tab1, '') + self.right_widget.addTab(self.tab2, '') + self.right_widget.addTab(self.tab3, '') + self.right_widget.addTab(self.tab4, '') + + self.right_widget.setCurrentIndex(0) + self.right_widget.setStyleSheet('''QTabBar::tab{width: 0; \ + height: 0; margin: 0; padding: 0; border: none;}''') + + main_layout = QHBoxLayout() + main_layout.addWidget(left_widget) + main_layout.addWidget(self.right_widget) + main_layout.setStretch(0, 40) + main_layout.setStretch(1, 200) + main_widget = QWidget() + main_widget.setLayout(main_layout) + self.setCentralWidget(main_widget) + + # ----------------- + # buttons + + def button1(self): + self.right_widget.setCurrentIndex(0) + + def button2(self): + self.right_widget.setCurrentIndex(1) + + def button3(self): + self.right_widget.setCurrentIndex(2) + + def button4(self): + self.right_widget.setCurrentIndex(3) + + # ----------------- + # pages + + def ui1(self): + main_layout = QVBoxLayout() + main_layout.addWidget(QLabel('page 1')) + main_layout.addStretch(5) + main = QWidget() + main.setLayout(main_layout) + return main + + def ui2(self): + main_layout = QVBoxLayout() + main_layout.addWidget(QLabel('page 2')) + main_layout.addStretch(5) + main = QWidget() + main.setLayout(main_layout) + return main + + def ui3(self): + main_layout = QVBoxLayout() + main_layout.addWidget(QLabel('page 3')) + main_layout.addStretch(5) + main = QWidget() + main.setLayout(main_layout) + return main + + def ui4(self): + main_layout = QVBoxLayout() + main_layout.addWidget(QLabel('page 4')) + main_layout.addStretch(5) + main = QWidget() + main.setLayout(main_layout) + return main + + +if __name__ == '__main__': + app = QApplication(sys.argv) + ex = Window() + ex.show() + sys.exit(app.exec_()) \ No newline at end of file diff --git a/projetsysteme/views.py b/projetsysteme/views.py new file mode 100644 index 0000000..1ea8164 --- /dev/null +++ b/projetsysteme/views.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +"""This module provides views to manage the contacts table.""" + +from PyQt5.QtWidgets import ( + QLabel, QPushButton, QVBoxLayout +) + +from .settings import window_title +from .components import AbstractWindow, QPrimaryButton + + + +class Window(AbstractWindow): + """Main Window.""" + def __init__(self, parent=None): + """Initializer.""" + super().__init__() + self.setWindowTitle(window_title) + + self.setupUI() + + def setupUI(self): + """Setup the main window's GUI.""" + # Create Buttons + self.addButton = QPrimaryButton("Add") + self.deleteButton = QPushButton("Delete") + self.clearAllButton = QPushButton("clear all") + + self.setToolBar([ + QPushButton('hello'), + QPushButton('world') + ]) + + # Lay out the GUI + sidebarLayout = QVBoxLayout() + sidebarLayout.addWidget(self.addButton) + sidebarLayout.addWidget(self.deleteButton) + sidebarLayout.addWidget(self.clearAllButton) + + + mainLayout = QVBoxLayout() + label = QLabel() + label.setText("Hello world") + mainLayout.addWidget(label) + + self.setupSidebarLayout(sidebarLayout, mainLayout) + + diff --git a/start.py b/start.py new file mode 100644 index 0000000..0ee3543 --- /dev/null +++ b/start.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# rpcontacts_project/rpcontacts.py + +"""This module provides RP Contacts entry point script.""" + +from projetsysteme.main import main + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..e69de29