<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Help changing someone else&#x27;s code (default window size)]]></title><description><![CDATA[<p dir="auto">First, I must tell you that I am completely new to both Python and QT.<br />
I recently built a book scanning device according to <a href="https://note.com/fynote1009/n/n2df494d39fbb" target="_blank" rel="noopener noreferrer nofollow ugc">these instructions</a>. The designer also made image capture software just for this device, which is fine, but they wrote the code on the assumption that a large monitor would be used. Without realizing this, I purchased a 7" Capacitive Touch Screen For Raspberry Pi (1024*600), and when I ran the program, only the upper left corner was visible. When I resize the window, the text and buttons become illegible and unusable. I figured out that the program (which can be found <a href="https://github.com/FYGitHub1009/SimpleBookCapture" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>) uses QT, and furthermore I think I tracked down the culprit to this bit of code in the main file (SimpleBookCapture dot py):</p>
<pre><code>        # メインWindow初期設定
        self.resize(int(1920*3/4), int(1080*3/4))
        self.move(100, 100)
        self.setWindowTitle('Simple Book Capture Ver.0.0.1')
        self.show()
</code></pre>
<p dir="auto">(The Japanese means "Main Window Initial Settings.") I believe there is some way to replace those numbers with percentages of available screen, such as "0.9."<br />
Then there remains the problem of tweaking how other things get scaled, so that they are legible and useable on my little monitor, but I haven't looked for that code yet.<br />
<a href="https://video.everythingbagel.me/w/4dvYcSdhdVB2fWWULjmXDh" target="_blank" rel="noopener noreferrer nofollow ugc">Here's a video of me launching the program and resizing the screen</a>. Although the text on the screen is mostly Japanese, you can see by looking at the numbers that the top and bottom of all text gets chopped off a bit, so that "100" looks like "|( )( )."<br />
This scanner is made to be used at the Kyoto International Manga Museum, and will be used by a number of people besides me. I can't expect them all to learn how to resize the window (which is awkward) and make sense of the cramped results.<br />
Any guidance would be very much appreciated.</p>
]]></description><link>https://forum.qt.io/topic/159699/help-changing-someone-else-s-code-default-window-size</link><generator>RSS for Node</generator><lastBuildDate>Thu, 06 Aug 2026 18:09:16 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/159699.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 13 Nov 2024 13:39:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Help changing someone else&#x27;s code (default window size) on Fri, 15 Nov 2024 08:35:31 GMT]]></title><description><![CDATA[<p dir="auto">There are items in this main window that I don't need and can't use anyway, and I found those components in a script named "CameraSettingsPage dot py."<br />
I was able to delete the "Save RAW and Meta data" item easily, so I saved a whole line of space there, but when I deleted code for the "Sensor mode" (which also seems to be unusable)...</p>
<pre><code>        # センサモードのコンボボックス
                self.sensorFormat = QComboBox()
                #self.sensorFormat.addItem("Default")
                self.sensorFormat.addItems([f'{x["formatfsensor"].format} {x["size"]}' for x in picam2s[camid].sensor_modes])
                # 最大の解像度(4608x2592)に設定
                # プレビューとキャプチャの画角違い防止のため固定
                self.sensorFormat.setCurrentIndex(2)
                self.sensorFormat.setEnabled(False)
                formLayout.addRow("センサーモード", self.sensorFormat)
</code></pre>
<p dir="auto">...the program would no longer launch. I assume there are references to things in this code elsewhere in this script (or maybe other scripts) that I would also need to delete or modify.<br />
I also would like to get rid of the "Image Size" (画像サイズ) item just below the sensor mode item.</p>
<pre><code>        # 画像サイズ反映ボタン
        self.resButton = QPushButton("反映")
        self.resButton.setEnabled(False)
        # 画像サイズ反映ボタンクリック時の動作
        self.resButton.clicked.connect(self.on_resButton_clicked)
        
        # 画像の縦横サイズを変更時は反映ボタンを有効化
        self.imageWidth.valueChanged.connect(lambda: self.resButton.setEnabled(True))
        self.imageHeight.valueChanged.connect(lambda: self.resButton.setEnabled(True))
        
        # 画像サイズ
        resolution = QWidget()
        resHLayout = QHBoxLayout()
        resolution.setLayout(resHLayout)
        resHLayout.addWidget(self.imageWidth)
        resHLayout.addWidget(QLabel("x"), alignment=Qt.AlignHCenter)
        resHLayout.addWidget(self.imageHeight)
        resHLayout.addWidget(QLabel(" "), alignment=Qt.AlignHCenter)
        resHLayout.addWidget(self.resButton)
        formLayout.addRow("画像サイズ", resolution)
</code></pre>
<p dir="auto">Getting rid of those two would make this window plenty usable and legible. (As it is, the "Rotation" control, just below the "Image size" control, is unusable with the window sized to fit my screen, because the button isn't visible.)</p>
]]></description><link>https://forum.qt.io/post/814747</link><guid isPermaLink="true">https://forum.qt.io/post/814747</guid><dc:creator><![CDATA[Rachel_T]]></dc:creator><pubDate>Fri, 15 Nov 2024 08:35:31 GMT</pubDate></item><item><title><![CDATA[Reply to Help changing someone else&#x27;s code (default window size) on Fri, 15 Nov 2024 07:37:32 GMT]]></title><description><![CDATA[<p dir="auto">Thanks to both of you for your responses! Deleting the "resize" line and changing "self.show" to "self.showMaximized" did the trick. Now I just need to see what I can do to make it all more legible.</p>
]]></description><link>https://forum.qt.io/post/814731</link><guid isPermaLink="true">https://forum.qt.io/post/814731</guid><dc:creator><![CDATA[Rachel_T]]></dc:creator><pubDate>Fri, 15 Nov 2024 07:37:32 GMT</pubDate></item><item><title><![CDATA[Reply to Help changing someone else&#x27;s code (default window size) on Wed, 13 Nov 2024 14:21:05 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to the forum :)</p>
<p dir="auto">I've read bits of the original code and couldn't find anything suspicious.<br />
So even when you resize the window manually, the result is not satisfying or what you expect?<br />
In your video it looks like some comboBoxes (the elements the with a drop-down menu) are not displayed correctly?!</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rachel_t">@<bdi>Rachel_T</bdi></a> said in <a href="/post/814551">Help changing someone else's code (default window size)</a>:</p>
<blockquote>
<p dir="auto">I believe there is some way to replace those numbers with percentages of available screen, such as "0.9."<br />
Then there remains the problem of tweaking how other things get scaled, so that they are legible and useable on my little monitor</p>
</blockquote>
<p dir="auto">Yes it should be possible, in fact the actual code already uses some kind of scaling, because as you can see</p>
<blockquote>
<pre><code>self.resize(int( 1920*3/4 ), int( 1080*3/4) )
</code></pre>
</blockquote>
<p dir="auto">it uses  3/4 of 1920x1080 (which equals the size of FullHD resolution). I assume it's due to some scaling of their original screen.</p>
<p dir="auto">Ah, while I am typing this, I see @J-Hilk has replied.</p>
<p dir="auto">You can use code like he posted above to get your current screen size</p>
<p dir="auto">(This part here)</p>
<pre><code>screen = QApplication.primaryScreen()
screen_size = screen.size()
screen_width = screen_size.width()
screen_height = screen_size.height()

# this does not need to be 3/4...
# play around with different sizes until you get what you want
self.resize(int(screen_width * 3 / 4), int(screen_height * 3 / 4))

# this is where the window appears on your screen.
# topleft corner is the origin of the coordinate system ( 0 / 0 )
self.move((screen_width - self.width()) / 2, (screen_height - self.height()) / 2)
</code></pre>
<p dir="auto">or you try one of</p>
<pre><code> self.showFullScreen()
</code></pre>
<p dir="auto">or</p>
<pre><code>  self.showMaximized()
</code></pre>
<p dir="auto">instead of just <code>self.show()</code></p>
<p dir="auto">But I don't know for sure whether it will work (and set the correct size) on PyQt and your Raspberry.</p>
<p dir="auto">Edit:</p>
<p dir="auto">@J-Hilk The original code says PyQt5... Can't tell if there are possible issues with scaling and screen sizes (:<br />
Could not find any trace of something around <code>HighDPIScaling</code> or so...</p>
]]></description><link>https://forum.qt.io/post/814555</link><guid isPermaLink="true">https://forum.qt.io/post/814555</guid><dc:creator><![CDATA[Pl45m4]]></dc:creator><pubDate>Wed, 13 Nov 2024 14:21:05 GMT</pubDate></item><item><title><![CDATA[Reply to Help changing someone else&#x27;s code (default window size) on Wed, 13 Nov 2024 13:59:51 GMT]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I'm not a python guy, and you didn't tell us what bindings you're using, but I know generally what to look for/turn to in Qt:<br />
So here's a ChatGPT example. You get the basic premise, but no guarantee this example is actually compiling and running :P</p>
<pre><code>from PyQt6.QtWidgets import QApplication, QMainWindow, QLabel
from PyQt6.QtGui import QScreen, QFont

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        screen = QApplication.primaryScreen()
        screen_size = screen.size()
        screen_width = screen_size.width()
        screen_height = screen_size.height()

        self.resize(int(screen_width * 3 / 4), int(screen_height * 3 / 4))
        self.move((screen_width - self.width()) // 2, (screen_height - self.height()) // 2)

        font_size = int(screen_height * 0.02)
        font = QFont("Arial", font_size)

        self.setFont(font)


        label = QLabel("Welcome to Simple Book Capture!", self)
        label.setFont(font)
        label.move(50, 50)


        self.setWindowTitle('Simple Book Capture Ver.0.0.1')
        self.show()


app = QApplication([])
window = MainWindow()
app.exec()
</code></pre>
]]></description><link>https://forum.qt.io/post/814554</link><guid isPermaLink="true">https://forum.qt.io/post/814554</guid><dc:creator><![CDATA[J.Hilk]]></dc:creator><pubDate>Wed, 13 Nov 2024 13:59:51 GMT</pubDate></item></channel></rss>