Skip to content

Commit

Permalink
beginning of new UI
Browse files Browse the repository at this point in the history
  • Loading branch information
safirex committed Aug 6, 2022
1 parent 4a07d36 commit 449366f
Show file tree
Hide file tree
Showing 3 changed files with 226 additions and 0 deletions.
95 changes: 95 additions & 0 deletions forms/form.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QWidget" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonUpdate">
<property name="text">
<string>update</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0">
<widget class="QLabel" name="LabelLocalProgress">
<property name="text">
<string>Local Progress</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="LabelGlobalProgress">
<property name="text">
<string>Global Progress</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QProgressBar" name="progressBarGlobal">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QProgressBar" name="progressBarLocal">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QListWidget" name="listWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
48 changes: 48 additions & 0 deletions forms/listItem.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>200</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
83 changes: 83 additions & 0 deletions gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import sys
import os


# from PySide2.QtWidgets import QApplication, QWidget
# from PySide2.QtCore import QFile
# from PySide2.QtUiTools import QUiLoader

from PyQt5 import uic
from PyQt5.QtWidgets import QApplication, QWidget, QListWidget, QVBoxLayout, QLabel, QPushButton, QListWidgetItem, \
QHBoxLayout
from regex import D
from src.main_functions import *


class MainWindow(QWidget):
def __init__(self):
super().__init__()
self.load_ui()
self.init()

def load_ui(self):
uic.loadUi("forms/form.ui", self)
styleSheetStr = str(open("./css/style.scss","r").read())
self.setStyleSheet(styleSheetStr)

def init(self):
print('init');
self.populate_listview()
self.pushButtonUpdate.clicked.connect(self.updateNovels)


def populate_listview(self):
novelList = findNovel('')

for novel in novelList:
novelInfo = getNovelInfoFromFolderName(novel)
novel=Novel(novelInfo[1],novelInfo[0],False)

# add item to the listview
listItem = QListWidgetItem(self.listWidget)
item_widget = ListItemFromUI(novel)
listItem.setSizeHint(item_widget.sizeHint())
self.listWidget.addItem(listItem)
self.listWidget.setItemWidget(listItem, item_widget)
def novel_update_notice(self,nb_novel,nb_novel_to_update):
self.progressBarGlobal.setValue( nb_novel/nb_novel_to_update *100)

def chapter_update_notice(self,nb_chap,nb_chap_to_update):
self.progressBarLocal.setValue( nb_chap/nb_chap_to_update *100)

def updateNovels(self):
print('updatesing')
for novel in self.listWidget:
pass


class ListItemFromUI(QWidget):
def __init__(self,novel:Novel):
super().__init__()
self.novel = Novel;
self.text = novel.titre
uic.loadUi("forms/listItem.ui", self)
self.init()

def init(self):
self.label_2.setText(self.text)




if __name__ == "__main__":
app = QApplication([])
widget = MainWindow()
widget.show()
sys.exit(app.exec_())

# app = QtWidgets.QApplication(sys.argv)

# window = uic.loadUi("form.ui")
# window.show()
# # app.exec()
# sys.exit(app.exec_())

0 comments on commit 449366f

Please sign in to comment.