-
-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1794 from mhsmith/gtk-containers
Modify container handling for GTK
- Loading branch information
Showing
54 changed files
with
510 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,3 @@ def _create_dialog(self): | |
True, | ||
) | ||
self._dialog.show() | ||
|
||
def rehint(self): | ||
return super().rehint() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Issues with reducing the size of windows on GTK have been resolved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The handling of GTK layouts has been modified to reduce the frequency and increase the accuracy of layout results. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Resize Test | ||
=========== | ||
|
||
Test app that demonstrates resizing of widgets and windows. | ||
|
||
Quickstart | ||
~~~~~~~~~~ | ||
|
||
To run this example: | ||
|
||
$ pip install toga | ||
$ python -m resize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
[build-system] | ||
requires = ["briefcase"] | ||
|
||
[tool.briefcase] | ||
project_name = "Resize Test" | ||
bundle = "org.beeware" | ||
version = "0.0.1" | ||
url = "https://beeware.org" | ||
license = "BSD license" | ||
author = 'Tiberius Yak' | ||
author_email = "[email protected]" | ||
|
||
[tool.briefcase.app.resize] | ||
formal_name = "Resize Test" | ||
description = "A testing app" | ||
sources = ['resize'] | ||
requires = [ | ||
'../../core', | ||
] | ||
|
||
|
||
[tool.briefcase.app.resize.macOS] | ||
requires = [ | ||
'../../cocoa', | ||
'std-nslog>=1.0.0', | ||
] | ||
|
||
[tool.briefcase.app.resize.linux] | ||
requires = [ | ||
'../../gtk', | ||
] | ||
|
||
[tool.briefcase.app.resize.windows] | ||
requires = [ | ||
'../../winforms', | ||
] | ||
|
||
# Mobile deployments | ||
[tool.briefcase.app.resize.iOS] | ||
requires = [ | ||
'../../iOS', | ||
'std-nslog>=1.0.0', | ||
] | ||
|
||
[tool.briefcase.app.resize.android] | ||
requires = [ | ||
'../../android', | ||
] | ||
|
||
# Web deployment | ||
[tool.briefcase.app.resize.web] | ||
requires = [ | ||
'../../web', | ||
] | ||
style_framework = "Bootstrap v4.6" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from resize.app import main | ||
|
||
if __name__ == "__main__": | ||
main().main_loop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import toga | ||
from toga.style import Pack | ||
from toga.style.pack import COLUMN, ROW | ||
|
||
|
||
class SizeButton(toga.Button): | ||
def __init__(self, text, *, value, max, on_press): | ||
self.value = value | ||
self.max = max | ||
self.on_press_impl = on_press | ||
super().__init__(text, on_press=self.on_press_wrapper) | ||
|
||
def on_press_wrapper(self, button): | ||
self.value = (self.value + 1) % (self.max + 1) | ||
self.on_press_impl(button) | ||
|
||
|
||
class SizePanel(toga.Box): | ||
def __init__(self, title, *, on_change): | ||
self.on_change = on_change | ||
self.width, self.height = ( | ||
SizeButton(text, value=1, max=6, on_press=self.on_press) | ||
for text in ["W", "H"] | ||
) | ||
self.flex = SizeButton("F", value=0, max=3, on_press=self.on_press) | ||
super().__init__( | ||
style=Pack(direction=COLUMN, alignment="center"), | ||
children=[ | ||
toga.Label(title.upper(), style=Pack(font_weight="bold")), | ||
toga.Box( | ||
style=Pack(direction=ROW), | ||
children=[self.width, self.height, self.flex], | ||
), | ||
], | ||
) | ||
self.on_press(None) | ||
|
||
def on_press(self, button): | ||
self.on_change(self, self.width.value, self.height.value, self.flex.value) | ||
|
||
|
||
class Resize(toga.App): | ||
def startup(self): | ||
self.text_label, self.style_label = ( | ||
toga.Label("", style=Pack(background_color="cyan")) for i in range(2) | ||
) | ||
main_box = toga.Box( | ||
style=Pack(direction=COLUMN), | ||
children=[ | ||
toga.Box( | ||
style=Pack(direction=ROW), | ||
children=[ | ||
SizePanel("Text", on_change=self.on_change_text), | ||
toga.Box(style=Pack(flex=1)), | ||
SizePanel("Style", on_change=self.on_change_style), | ||
], | ||
), | ||
toga.Box( | ||
style=Pack(direction=ROW), | ||
children=[ | ||
self.text_label, | ||
toga.Label("", style=Pack(background_color="pink", flex=1)), | ||
toga.Label("", style=Pack(background_color="yellow", flex=1)), | ||
self.style_label, | ||
], | ||
), | ||
toga.Box(style=Pack(background_color="pink", flex=1)), | ||
toga.Box(style=Pack(background_color="yellow", flex=1)), | ||
], | ||
) | ||
|
||
self.main_window = toga.MainWindow(title=self.formal_name) | ||
self.main_window.content = main_box | ||
self.main_window.show() | ||
|
||
def on_change_text(self, panel, width, height, flex): | ||
text = "\n".join(" ".join("X" for i in range(width)) for j in range(height)) | ||
setattr_if_changed(self.text_label, "text", text) | ||
setattr_if_changed(self.text_label.style, "flex", flex) | ||
|
||
def on_change_style(self, panel, width, height, flex): | ||
# Increment should be large enough that the minimum window width can be determined | ||
# by either the buttons or the labels, depending on the labels' size. | ||
INCREMENT = 70 | ||
setattr_if_changed(self.style_label.style, "width", width * INCREMENT) | ||
setattr_if_changed(self.style_label.style, "height", height * INCREMENT) | ||
setattr_if_changed(self.style_label.style, "flex", flex) | ||
|
||
|
||
def setattr_if_changed(obj, name, value): | ||
"""Ensure that each button click only changes one thing.""" | ||
|
||
old_value = getattr(obj, name) | ||
if old_value != value: | ||
setattr(obj, name, value) | ||
|
||
|
||
def main(): | ||
return Resize("Resize", "org.beeware.resize") |
Oops, something went wrong.