<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>On 9/10/21 6:59 AM, Maurizio Berti wrote:</p>
<p>Thank you very much for your code, I will never forget your
effort to help me.</p>
<p>While you lost your time (friendly) I tried to put togheter a
simple piece of code to show what I would like to obtain. Of
course it doesnt work mainly because I miss how to handle UI
classes. I would like to read your opinion<br>
</p>
<p>Lets go:</p>
<p><a class="moz-txt-link-freetext" href="https://i.imgur.com/2URinRF.jpg">https://i.imgur.com/2URinRF.jpg</a> Here you will see where the
scroll class should show the result of the query. (<span
style="color:#94558d;">self</span>.stripTable <span
style="color:#828282;">= </span>QtWidgets.<span
style="color:#66d9ef;">QTableWidget</span>(<span
style="color:#94558d;">self</span>.Strip_tab))</p>
<p>##### setup.py #####</p>
<p>from PyQt5.QtWidgets import QApplication, QWidget, QPushButton<br>
from strips import *<br>
<br>
class App(QWidget):<br>
def __init__(self):<br>
super().__init__()<br>
self.initUI()<br>
<br>
def initUI(self):<br>
self.setGeometry(10, 10, 320, 300)<br>
button = QPushButton('Select', self)<br>
button.move(100, 70)<br>
button.clicked.connect(self.on_click)<br>
self.show()<br>
def on_click(self):<br>
anno = '2021'<br>
mese = '9'<br>
cursor = 'xx'<br>
self.stripTable = QtWidgets.QTableWidget(self.Strip_tab)<br>
'''<br>
This should be added since the result of SomeWindow()
should be shown into<br>
a tab of the project, otherwise in a popup menu<br>
'''<br>
SomeWindow.createTable(self, anno, mese, cursor)<br>
#SomeWindow.createTable(self, self.self.stripTable, anno,
mese, cursor)<br>
<br>
if __name__ == '__main__':<br>
app = QApplication(sys.argv)<br>
ex = App()<br>
sys.exit(app.exec_())<br>
</p>
<p>###### strips.py #####<br>
</p>
<p>import sys<br>
import calendar<br>
<br>
#from functions import *<br>
from PyQt5 import QtCore, QtGui, QtWidgets<br>
from PyQt5.QtWidgets import QMainWindow, QTableWidget<br>
from single import Strip_MainWindow<br>
<br>
class SpecialStyledItemDelegate(QtWidgets.QStyledItemDelegate):<br>
def __init__(self, parent=None):<br>
super().__init__(parent)<br>
self._values = dict()<br>
<br>
def add_text(self, text, row):<br>
self._values[row] = text<br>
<br>
def initStyleOption(self, option, index):<br>
super().initStyleOption(option, index)<br>
row = index.row()<br>
if row in self._values:<br>
option.text = self._values[row]<br>
option.displayAlignment = QtCore.Qt.AlignCenter<br>
<br>
class SomeWindow(QMainWindow, Strip_MainWindow):<br>
def __init__(self, anno, month, cursor):<br>
super().__init__()<br>
self.setupUiStrip(self)<br>
<br>
def createTable(self, anno, mese, cursor): #I will need them
in production<br>
zz = 'table_'<br>
cc = 0<br>
for aa in range(1, 13):<br>
self.vol_name = 'JOHN DOE'<br>
self.alphamese = 'Twisted'<br>
# table ='zz%s'%(str(cc))<br>
self.table =
QTableWidget(self.scrollAreaWidgetContents)<br>
self.table.setGeometry(QtCore.QRect(0, 5, 150, 597))<br>
sizePolicy =
QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
QtWidgets.QSizePolicy.Expanding)<br>
self.table.setSizePolicy(sizePolicy)<br>
self.table.setSizeAdjustPolicy(self.table.AdjustToContents)<br>
self.table.setObjectName("StripTable")<br>
self.table.setRowCount(33)<br>
self.table.setColumnCount(3)<br>
self.special_delegate = SpecialStyledItemDelegate()<br>
self.table.setItemDelegate(self.special_delegate)<br>
h_header = self.table.horizontalHeader()<br>
h_header.hide()<br>
for i in range(h_header.count() - 1):<br>
h_header.setSectionResizeMode(i,
QtWidgets.QHeaderView.ResizeToContents)<br>
h_header.setSectionResizeMode(2,
QtWidgets.QHeaderView.Fixed)<br>
v_header = self.table.verticalHeader()<br>
v_header.hide()<br>
v_header.setDefaultSectionSize(17)<br>
self.table.setSpan(1, 0, 1, 3)<br>
self.table.setSpan(0, 0, 1, 3)<br>
zx = 1<br>
self.special_delegate.add_text(self.vol_name, 0)<br>
self.special_delegate.add_text(self.alphamese, 1)<br>
for zx in range(1, 10):<br>
dow = "do{}".format(zx)<br>
value = "AAAAAAAA{}".format(zx)<br>
self.table.setItem(zx + 1, 0,
QtWidgets.QTableWidgetItem(str(zx)))<br>
self.table.setItem(zx + 1, 1,
QtWidgets.QTableWidgetItem(dow))<br>
item = QtWidgets.QTableWidgetItem(value)<br>
item.setTextAlignment(QtCore.Qt.AlignCenter)<br>
self.table.setItem(zx + 1, 2, item)<br>
self.layout.addWidget(self.table)<br>
<br>
'''<br>
app = QApplication(sys.argv)<br>
window = Ui_MainWindow()<br>
window.show()<br>
app.exec()<br>
'''</p>
<p>##### single.py #####</p>
<p>from PyQt5 import QtCore, QtGui, QtWidgets<br>
from PyQt5.QtWidgets import QTableWidget<br>
<br>
<br>
class SpecialStyledItemDelegate(QtWidgets.QStyledItemDelegate):<br>
def __init__(self, parent=None):<br>
super().__init__(parent)<br>
self._values = dict()<br>
<br>
def add_text(self, text, row):<br>
self._values[row] = text<br>
<br>
def initStyleOption(self, option, index):<br>
super().initStyleOption(option, index)<br>
row = index.row()<br>
if row in self._values:<br>
option.text = self._values[row]<br>
option.displayAlignment = QtCore.Qt.AlignCenter<br>
<br>
class Strip_MainWindow(object):<br>
def __init__(self):<br>
super().__init__()<br>
self.setupUi(self,)<br>
<br>
def setupUiStrip(self, MainWindow,anno,mese,cursor):<br>
MainWindow.setObjectName("MainWindow")<br>
MainWindow.resize(800, 600)<br>
self.centralwidget = QtWidgets.QWidget(MainWindow)<br>
self.centralwidget.setObjectName("centralwidget")<br>
self.horizontalLayout =
QtWidgets.QHBoxLayout(self.centralwidget)<br>
self.horizontalLayout.setObjectName("horizontalLayout")<br>
self.scrollArea =
QtWidgets.QScrollArea(self.centralwidget)<br>
self.scrollArea.setWidgetResizable(True)<br>
self.scrollArea.setObjectName("scrollArea")<br>
self.scrollAreaWidgetContents = QtWidgets.QWidget()<br>
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0,
0, 780, 539))<br>
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")<br>
self.layout =
QtWidgets.QHBoxLayout(self.scrollAreaWidgetContents)<br>
self.layout.setContentsMargins(0, 0, 0, 0)<br>
self.layout.setObjectName("layout")<br>
#self.layout.addWidget(self.table)<br>
self.scrollArea.setWidget(self.scrollAreaWidgetContents)<br>
self.horizontalLayout.addWidget(self.scrollArea)<br>
MainWindow.setCentralWidget(self.centralwidget)<br>
self.menubar = QtWidgets.QMenuBar(MainWindow)<br>
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 19))<br>
self.menubar.setObjectName("menubar")<br>
MainWindow.setMenuBar(self.menubar)<br>
self.statusbar = QtWidgets.QStatusBar(MainWindow)<br>
self.statusbar.setObjectName("statusbar")<br>
MainWindow.setStatusBar(self.statusbar)<br>
self.retranslateUi(MainWindow)<br>
QtCore.QMetaObject.connectSlotsByName(MainWindow)<br>
<br>
def retranslateUi(self, MainWindow):<br>
_translate = QtCore.QCoreApplication.translate<br>
MainWindow.setWindowTitle(_translate("MainWindow",
"MainWindow"))<br>
<br>
</p>
<blockquote type="cite"
cite="mid:CAPn+-XRuAyCY3wSsN1M6BGtaxwtV9xnUshbhj-ATdjQJXhqraw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">Il giorno
gio 9 set 2021 alle ore 14:02 paparucino
<<a href="mailto:paparucino@gmail.com"
moz-do-not-send="true">paparucino@gmail.com</a>>
ha scritto:<br>
</div>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">[...]<br>
That link only shows instructions on how
to prepare a good ssce but I <br>
don't see any references to a mailing list</blockquote>
</div>
</div>
<div dir="ltr"><br>
</div>
<div>What Florian meant was that you should use
the instructions on that website and then post
to *this* mailing list.</div>
<div dir="ltr"><br>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">Il giorno
mer 8 set 2021 alle ore 16:47 paparucino
<<a href="mailto:paparucino@gmail.com"
moz-do-not-send="true">paparucino@gmail.com</a>>
ha scritto:<br>
</div>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div>
<p>I never edit the ui file. I keep it as
a base and eventually I create many .py
files depending on how the debug goes. I
know that it is confusing and that I
fill the dir with files but sometimes I
start from an idea and as everything
evolves I can change my mind and
therefore I have a base plus a certain
series of more or less functional back
ups<br>
</p>
</div>
</blockquote>
<div>Creating multiple UI files for the same
interface is not an issue, as long as it's
only done for UX purposes (aesthetic or
design).</div>
I've prepared a basic example of what you
might want to achieve. There's a basic
QMainWindow with an *empty* scroll area (but
an existing layout), and the code that allows
you to create as many tables as you want.</div>
</div>
<div dir="ltr"><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<p>Pls, don't hate me. I tried your code but it doesnt solve my
problem. I already obtained that, let me call this way, scrollArea
via designer. My problem was/is to pass variables from another
class (see setup.py) to the scrollArea, then show the result into
the strip tab (see picture) <br>
</p>
<p>Forgive me</p>
<p>paparucino</p>
<p><br>
</p>
<br>
</body>
</html>