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

Add "rehint()" on the background of the widget after changing font size [Core] [Cocoa] #176

Open
Dayof opened this issue Jun 7, 2017 · 6 comments

Comments

@Dayof
Copy link
Contributor

@Dayof Dayof commented Jun 7, 2017

To reproduce this error I made this code https://gist.github.com/Dayof/f25e73a902b3c1d0c2b83dc6e3fba8f9 .

The following image shows the a normal behavior of a Label, with the Font size modified, inside of a Box:

1

And in the next image shows the a bad behavior of a Label, with the Font size modified, inside of a Box and this Box is inside of a SplitContainer:

2

After applying a test_status.rehint() the size of the Label adjust as should it be:

3

This method (rehint()) should be activated on Toga background after change a Labels Font, without forcing the user worry about this.

@barryjohnthompson
Copy link

@barryjohnthompson barryjohnthompson commented Feb 12, 2018

Hi! I'd be interested in taking a look at this issue, if it still needs to be done?

@Donyme
Copy link

@Donyme Donyme commented Mar 8, 2018

AttributeError: 'Label' object has no attribute 'set_font'
Am receiving this error upon running the code

@mav-erick
Copy link
Contributor

@mav-erick mav-erick commented Jan 21, 2019

@Dayof @freakboy3742 I am facing the same problem as @Donyme. set_font is implemented in
toga/src/cocoa/toga_cocoa/widgets/label.py
But not in
toga/src/core/toga/widgets/label.py
As far as I can work out this is where the import is from and hence it is throwing an AttributeError. Is this an implementation that this project has moved on from, or is it missing? As I am new to this codebase I am not able to work it out. Could anyone point me in the right direction, if this is still an issue?

@freakboy3742
Copy link
Member

@freakboy3742 freakboy3742 commented Jan 21, 2019

@mav-erick It's entirely expected that the core widget doesn't have a set_font method. The core widget has a font property; altering that attribute calls set_font on the backend. My guess is that it's the property setter that needs the rehint call.

(This is a general pattern in Toga - the front end exposes the "most Pythonic" API it can; the backend then defines specific "do X" APIs to implement that frontend design)

@RishabhAgarwal-2001
Copy link
Contributor

@RishabhAgarwal-2001 RishabhAgarwal-2001 commented Jun 29, 2020

@freakboy3742 I am facing issue in changing the font and colour of the label widget in Toga Gtk implementation. I tried altering the font property of the label through the code below, but no change was noticed.

class Test_App( toga.App ) :
    def startup( self ) :
        self.main_window = toga.MainWindow( title=self.name )
        body_box = toga.Box(id='Main Box')
        label = toga.Label("Quick Quiz")
        label.style.font = toga.fonts.Font(family='Times New Roman', size=50)
        body_box.add(label)
        self.main_window.content = body_box
        self.main_window.show()

image

Is this functionality still to be coded for Linux?

@freakboy3742
Copy link
Member

@freakboy3742 freakboy3742 commented Jun 29, 2020

@RishabhAgarwal-2001 Well, the fact that the font isn't changing would seem to suggest that it is... :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants