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

qlineargradient x1,y1,x2,y2 values can be floats! #42

Closed
ewerybody opened this issue Sep 2, 2019 · 3 comments · Fixed by #40
Closed

qlineargradient x1,y1,x2,y2 values can be floats! #42

ewerybody opened this issue Sep 2, 2019 · 3 comments · Fixed by #40
Assignees
Milestone

Comments

@ewerybody
Copy link
Contributor

Turns out its actually not a problem to put float values into the x1,y1,x2,y2 coordinate values of a qlineargradient liek:

s = 'background: qlineargradient(x2: 0.0, y2:2.0, stop:0 rgb(80,20,20), stop:1 rgb(75,175,75));'
x.btn.setStyleSheet(s)

Unfortunately when compiling with qtsass the regular expression in conformers.py line 49 breaks on these. As soon as one replaces the floats with ints all is fine again.

Unfortunately again I have no clue how to make the re accept float values instead of the ints or anything else. It works with variables for instance.

qss_pattern = re.compile(
    r'qlineargradient\('
    r'((?:(?:\s+)?(?:x1|y1|x2|y2):(?:\s+)?[0-9A-Za-z$_-]+,?)+)'  # coords 🤷‍♂️🤷‍♂️🤷‍♂️
    r'((?:(?:\s+)?stop:.*,?)+(?:\s+)?)?'  # stops
    r'\)',
    re.MULTILINE,
)

This is probably an easy one for someone who's into regular expressions?

@goanpeca
Copy link
Member

goanpeca commented Sep 2, 2019

@ewerybody sure, I will fix it ;-),

Thanks for the help with the project!

@goanpeca goanpeca self-assigned this Sep 2, 2019
@goanpeca goanpeca added this to the 1.0 milestone Sep 2, 2019
@ewerybody
Copy link
Contributor Author

ewerybody commented Sep 2, 2019

Oh a co-worker was just helping me with the re 🙈
I almost had it myself. Sure one needs to escape the dot...

qss_pattern = re.compile(
    r'qlineargradient\('
    r'((?:(?:\s+)?(?:x1|y1|x2|y2):(?:\s+)?[0-9A-Za-z$_\.-]+,?)+)'  # coords
    r'((?:(?:\s+)?stop:.*,?)+(?:\s+)?)?'  # stops
    r'\)',
    re.MULTILINE,
)

Voilà! I'll put up a PR?

ewerybody added a commit to ewerybody/qtsass that referenced this issue Sep 2, 2019
@ewerybody
Copy link
Contributor Author

Ooh I need the other one to finish first? Sorry. No rush!! 🙈

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

Successfully merging a pull request may close this issue.

2 participants