Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1. ScrollContainer bug 2. Box.clear() not work 3. open_file_dialog bug 4. a bug when obtaining resolution 5.switch bug #2076

Closed
leaffeather opened this issue Aug 11, 2023 · 1 comment
Labels
bug A crash or error in behavior.

Comments

@leaffeather
Copy link

Describe the bug

As the title says:

  1. When the ScrollContainer is in nested boxes, it will display incompletely at the first time. It will become normal after its father box is added again into the grandparent box. And when maximum the window, the ScrollContainer will not change accordingly.
  2. As the code shows, currently Box.clear() cannot work and the interim measure is using remove() method to remove children one by one.
  3. open_file_dialog does not work on Android
  4. There seems to be no function in toga to obtain resolution. However, if using pyautogui and screeninfo, when running on Android, the program will raise the following errors in terminal respectively:

(iResolutionWidth, iResolutionHeight) = pyautogui.size() # raise Error: com.chaquo.python.PyException: KeyError: 'DISPLAY'
ResolutionWidth = get_monitors()[0].width #raise Error: com.chaquo.python.PyException: DisplayConnectionError: Can't connect to display ":0": [Errno 2] No such file or directory

  1. When a switch is used to control the display of a box, I want to let the initial value as False, in other words, the target box should be hidden at the first. However, the initial value is set as False, but the box is still visible

Steps to reproduce

Issue 1:
The part of definition
`
self.boxEditCardBody = toga.Box(style = Pack(direction = COLUMN, flex = 1))

    sbEditCardBodyRow1 = toga.ScrollContainer(style = Pack(direction = COLUMN, flex = 1, background_color = TRANSPARENT), horizontal = False)

    self.lblEditCard_boxEditCardBody = toga.Label("", style = Pack(background_color = TRANSPARENT, flex = 1, font_weight = BOLD))
    boxEditCardBodyRow1Row2 = toga.Box(style = Pack(direction = COLUMN, flex = 1))
    self.lblCardName_boxEditCardBody = toga.Label("", style = Pack(background_color = TRANSPARENT, flex = 1))
    self.txtCardName_boxEditCardBody = toga.TextInput(style = Pack(flex = 1), on_change = self.cbValidateNameTxt)
    boxEditCardBodyRow1Row2.add(
        self.lblCardName_boxEditCardBody,
        self.txtCardName_boxEditCardBody
    )
    boxEditCardBodyRow1Row3 = toga.Box(style = Pack(direction = COLUMN,flex = 1))
    self.lblCardFrontFrontend_boxEditCardBody = toga.Label("", style = Pack(background_color = TRANSPARENT, flex = 1))
    txtCardFrontFrontend_boxEditCardBody = toga.TextInput(style = Pack(flex = 1))
    self.lblCardFrontBackend_boxEditCardBody = toga.Label("", style = Pack(background_color = TRANSPARENT, flex = 1))
    txtCardFrontBackend_boxEditCardBody = toga.TextInput(style = Pack(flex = 1))
    boxEditCardBodyRow1Row3.add(
        self.lblCardFrontFrontend_boxEditCardBody,
        txtCardFrontFrontend_boxEditCardBody,
        self.lblCardFrontBackend_boxEditCardBody,
        txtCardFrontBackend_boxEditCardBody
    )
    self.chkEnableCardBack = toga.Switch("", style = Pack(background_color = TRANSPARENT, flex = 1))
    self.boxEditCardBodyRow1Row5 = toga.Box(style = Pack(direction = COLUMN, flex = 1))
    self.lblCardBackFrontend_boxEditCardBody = toga.Label("", style = Pack(background_color = TRANSPARENT, flex = 1))
    txtCardBackFrontend_boxEditCardBody = toga.TextInput(style = Pack(flex = 1))
    self.lblCardBackBackend_boxEditCardBody = toga.Label("", style = Pack(background_color = TRANSPARENT, flex = 1))
    txtCardBackBackend_boxEditCardBody = toga.TextInput(style = Pack(flex = 1))
    self.boxEditCardBodyRow1Row5.add(
        self.lblCardBackFrontend_boxEditCardBody,
        txtCardBackFrontend_boxEditCardBody,
        self.lblCardBackBackend_boxEditCardBody,
        txtCardBackBackend_boxEditCardBody
    )

    sbEditCardBodyRow1.content = toga.Box(
        children=[
            self.lblEditCard_boxEditCardBody,
            boxEditCardBodyRow1Row2,
            boxEditCardBodyRow1Row3,
            self.chkEnableCardBack,
            self.boxEditCardBodyRow1Row5
        ],style = Pack(direction = COLUMN)
    )

    self.btnSaveCard_boxEditCardBody = toga.Button("", on_press = self.cbSaveCardOnPress)
    self.boxEditCardBody.add(
        sbEditCardBodyRow1,
        self.btnSaveCard_boxEditCardBody
    )`

The callback function
def cbAddACardOnPress(self, widget): while len(self.boxBody.children) != 0: self.boxBody.remove(self.boxBody.children[0]) self.boxBody.add(self.boxEditCardBody) while len(self.boxBody.children) != 0: # A BUG: It must be execute twice at the first time, or the scrollcontainer opened at the first time could be incomplete self.boxBody.remove(self.boxBody.children[0]) self.boxBody.add(self.boxEditCardBody)


Issue 5:
The part of definition
`
boxRow2_wndAddCard = toga.Box(style = Pack(direction = COLUMN, flex = 1, padding_top = 5))
self.chkEnableBack_wndAddCard = toga.Switch("", value = True, on_change = self.cbEnableBack)
# There is a bug that if initial value is False, the boxRow3 should be hidden but will still be visible on the condition of visibility = HIDDEN
boxRow2_wndAddCard.add(
self.chkEnableBack_wndAddCard
)

    self.boxRow3_wndAddCard = toga.Box(style = Pack(direction = COLUMN, padding_top = 5, flex = 1))
    boxRow3Row1_wndAddCard = toga.Box(style = Pack(direction = ROW))
    self.lblBackFrontend_WndAddCard = toga.Label("")
    boxRow3Row1_wndAddCard.add(
        self.lblBackFrontend_WndAddCard
    )

    boxRow3Row2_wndAddCard = toga.Box(style = Pack(direction = ROW, padding_top = 5))
    btnAddBackFrontend_wndAddCard = toga.Button("📂", on_press = self.cbBackFrontend)
    self.txtBackFrontendFilePath_wndAddCard = toga.TextInput(style = Pack(flex = 1), readonly = True)
    boxRow3Row2_wndAddCard.add(
        btnAddBackFrontend_wndAddCard,
        self.txtBackFrontendFilePath_wndAddCard
    )

    boxRow3Row3_wndAddCard = toga.Box(style = Pack(direction = ROW, padding_top = 5))
    self.lblBackBackend_WndAddCard = toga.Label("")
    boxRow3Row3_wndAddCard.add(
        self.lblBackBackend_WndAddCard
    )

    boxRow3Row4_wndAddCard = toga.Box(style = Pack(direction = ROW, padding_top = 5))
    btnAddBackBackend_wndAddCard = toga.Button("📂", on_press = self.cbBackBackend)
    self.txtBackBackendFilePath_wndAddCard = toga.TextInput(style = Pack(flex = 1), readonly = True)
    boxRow3Row4_wndAddCard.add(
        btnAddBackBackend_wndAddCard,
        self.txtBackBackendFilePath_wndAddCard
    )
    self.boxRow3_wndAddCard.add(
        boxRow3Row1_wndAddCard,
        boxRow3Row2_wndAddCard,
        boxRow3Row3_wndAddCard,
        boxRow3Row4_wndAddCard,
    )

The callback function
def cbEnableBack(self, widget):
if widget.value == True:
self.boxRow3_wndAddCard.style.update(visibility = VISIBLE)
else:
self.boxRow3_wndAddCard.style.update(visibility = HIDDEN)
`

Expected behavior

Waiting for the solutions

Screenshots

No response

Environment

  • Operating System: win11
  • Python version:3.8.17
  • Software versions:
    • Briefcase:
    • Toga: 0.3.1 (install via pip)
    • ...

Logs


Additional context

No response

@leaffeather leaffeather added the bug A crash or error in behavior. label Aug 11, 2023
@freakboy3742
Copy link
Member

Thanks for the report.

I believe 1, 2 and 5 have been fixed as part of our widget audit; the fixes are all in the main branch, and will be in the next release.

3 isn't a bug - it's a feature that hasn't been implemented. File access is complicated on Android; it's not as simple as just opening a file. See #1158 for an initial attempt at an implementation, and a discussion of the complications.

4 is also a feature request; we have an implementation in development (nearing completion) in #1930. There's no chance at all that pyautogui will work on Android (at least at present), because the code for pyautogui assumes that it's running on a desktop machine, so it will be looking for XWindows APIs to determine screen size - something that isn't present on Android.

On an administrative note - If you've found 5 problems, it's much more helpful to open 5 individual tickets. That way, the discussion about reproducing problem 5 won't get tied up in the discussions around the requirement of feature 3.

On the basis that all the issues you've raised have either been resolved, or aren't bugs as you've described them, I'm going to close this ticket.

If you're able to reproduce problems 1, 2 or 5 with the current main branch of Toga, please open individual tickets with reproduction instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior.
Projects
None yet
Development

No branches or pull requests

2 participants