-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
(GSoC) Port Cricket to use Toga, instead of Tkinter #58
Comments
This proposal was accepted for the 2017 GSoC. Project progress updates will be posted here by @Dayof. |
Prepare the field (1 week) [OK]
This task was acomplished when I started to elaborate the proposal with more details about the chunks. To understand what I would need to change on Cricket ( Tkinter has an architecture really alike Toga, with a class to start the application, then set the application/ window attributes, like title, geometry, etc. Every widget, core or general, was mapped and written in the proposal. |
In a Skype meeting with the mentor @freakboy3742 was asked these 2 questions, "what is important to maintain from the base code" and "which parts of Cricket would be good to add new features from Toga", and of course, first, he suggested me to take a look on the whole code to understand better what the project (Cricket) does and how it does. And to the second question, we've both agreed to think about this after the whole port of Cricket to Toga, then I could think to add more features or even rethink about the present layout. For the first question, as a good path to follow, he suggested me to solve a issue on Cricket that he found but wasn't written yet on GitHub. I created this issue on pybee/cricket. I took a look on the problem, recorded a video about the example that he explained and wrote the problem as an issue on the github repository. More details about this issue can be found on the ticket #59. After reproduce this problem like he told me, I went to search why Cricket was behaviouring like that. I made a top-down search to explore more deeply the problem. First went to To make sure that the ".join()" has a real effect on the system, a test was made to test the coverage of tests using unittest. This test can be found at test_unit_integration.py with the name This issue helped me to understand better the Cricket architecture and what would be good to maintain from the base code. |
Core Widgets (1.5 week) [OK]
After the preparation on the first week it's time to start the port to Toga! First, I created a new branch on my fork named toga to push the changes that I'll make on the files main.py and view.py. The first thing that I did was the cleanup of all the After no error complained on the cleanup, I inserted the basic structure to build a On the This changes can be seen on the commit ac2ad43. The errors dialogs also needed some change on the architecture, beginning with the inheritance of Before I make this change on After the commit beeware/toga@9d9c911 the menu builder become available to be add on the Each menu is compounded of:
Apart from the sub menu The sub menu |
At this point, the mentor @eliasdorneles asked me how to run the application that I'm constructing, so I told him to install I've start mapping where would be good to have the
The According to the above structure the basics modifications on the skeleton was made on the commits 285f1d5, b5abe93, 8c8e702 and d40ad60. In the addition of the SplitContainer and the OptionContainer were found some errors. These errors were reported in the issues beeware/toga#167, beeware/toga#168 and beeware/toga#169. These errors will be corrected following the proposal timeline. To continue the proposal even without dig more on those issues it was made a workaround, removing the footer for now and the outer box to not enter in conflict with the above errors. These changes was made on commit b3a1b9a. Face of the current application. Face of the current application with the error dialog from The three issues reported on the beginning of this report (beeware/toga#167, beeware/toga#168 and beeware/toga#169) was fixed, then the final layout using a |
The current status of the On the new version of The commit d49ec75, I made a draft of the font for the test status. Later, when the weight and the label color be ready this draft will be complete. For now that is all I can do with a During this widget's test, I also discovered a problem with the size of a |
This A toolbar was add to put the basics commands to use the This last core widget ends the |
General Widgets (7.5 weeks) [OK]Basic General Widgets (1.5 weeks)
The toolbar of the main window on the last version of the For the icons, I considered to take from the Ionicons, because is MIT licensed (100% free and open source). The following icons are those that I just downloaded and used: The "run selected" icon I made an edition with the "play" icon to make more sense about its functionality: I added these icons in the commits 10dc1a7 and d4c9b08. After create the commands on the Dialogs also has buttons, in the Some dialogs on the last version of
|
|
Some The output and error forms supposed to be hidden when no test was executed and show after run the tests, this feature is not implemented yet, so I report as an issue beeware/toga#181. I sent a PR beeware/toga#184 solving this problem. The commit 1a6c504 add this modification with the feature hide and show a The labels on the status bar was set on the commit 9b8f9cd. As a workaround of the issue beeware/toga#167, the layout become as follow:
The result of the current main window is : With the solution of 2 split containers inside of the window, I've found another feature that could be add on This last basic general widget ends the Week 4 of the GSoC proposal!! |
Intermediate General Widgets (1 week)
There were 2 types of text input on the last version of In the addition of the class This issue was reported on ticket beeware/toga#194. All the text inputs was add, the result is shown on the image bellow. Some errors were found, later they have to be fixed. The issue beeware/toga#194 was fixed and two PR was made (beeware/toga#204 and beeware/toga#206) to make the The final look for both texts inputs : |
The current status of this widget doesn't appear at all, this issue was reported on the ticket beeware/toga#189. Even with this problem I add the widget and its functionalities on the commit c82d037 and 8fe6f11. After beeware/toga#189 was fixed, another issue appeared, the Even with these above errors, inside of a The issues beeware/toga#195 and beeware/toga#196 were fixed, so a new commit (50b0866) was made on |
Advance General Widgets (5.0 weeks)
The |
The basic usage of the @freakboy3742 gave me a suggestion to add a new feature on the The commit f8360ce, I set the wait icon when the method that runs all the tests starts. Result: Since the The
The feature to change the color of a text on the The After the adaptation of the data source api of The feature to run multiple selected tests was implemented on Set icons using the The problem tree was set in the commit 6989ee4 on |
Layout Widgets (0 week) [OK]
Scroll containers was used on dialogs, but indirectly when
The main content of the application use Usage documentation -- last milestone (2 weeks) [OK]Some example codes was made when a PR was sent or a issue was created.
Final considerationsFinally the end of the proposal arrived! After this migration from
Here is the final demonstration of the current version of 😄 ✌️ |
Table of content
1 Abstract
1.1 Drawbacks of the existing GUI framework
Cricket's GUI interface is currently implemented using Tkinter, which has a lot of limitations. For example: Tkinter has no built-in table widget, while Toga does. Tkinter does not support CSS properties for styling the objects, while Toga supports because of the Colosseum framework, the (partial) implementation of the CSS box and the flexbox layout algorithm. Also, the Toga project is very active, the community is always developing and fixing issues, and looks / feels like a native app for multiple platforms.
1.2 Goals
The main goal is the complete port of Cricket to use Toga as the framework for GUI interface. The base logic is mostly complete, so firstly I will plan how to adapt the actual architecture of the view to use Toga widgets. If I find one widget that Cricket uses but isn't implemented on Toga, I will develop a contribution to this specific widget. This way the application will not lose the basics layout.
So, the proposal will not only focus on the port of Tkinter to Toga, but on mapping the necessary widgets for a real application using Toga framework.
1.3 Benefits
In addition of the advantages of using Toga instead of Tkinter as I highlighted on section 1.1, this is a opportunity to improve error handling and make better use of features that Toga has but Tkinter does not. It will be the first BeeWare project that “eats it is own dogwood".
2 The new framework
2.1 Overview
The application logic core will be preserved, migrating only the objects of Tkinter to Toga widgets. Both Tkinter and Toga are event oriented so a redesign of the architecture will not happen.
Example of a simple migration of a widget object of Tkinter to Toga:
Tkinter:
Toga:
2.2 Advantages
At the example above we can already see the first advantage of the migration, the CSS usage, allowing more flexibility of the UI design. Also there are widgets that exist only in Toga, like the Table widget. More features can be added from this migration.
3 Schedule and milestones
I am going to two events during the GSOC, one during June 15th-18th and one during the period August 1st-5th. But these events are academic and will not prevent me from working there.
Also, it is important to cite the days that I will probably work half of the time because of the exams I will have on college:
3.1 Prepare the field -- first milestone (1 week)
(From May 30 until June 5)
Before starting coding there are a few important things to do around the first week:
3.2 Port Cricket to use Toga -- second milestone (9 weeks)
(From June 6 until August 7)
Each part of this milestone will follow a development process cycle: build, test and document. I will focus only on the Cocoa platform on each improvement or development of widgets on Toga. All modifications on Cricket will be made on the files view.py and on main.py. For Toga, the additions/modifications will be made on widgets folder.
To elaborate this section of the proposal I mapped each object used with Tkinter that exists in Toga, some objects need to be explored with more details but the next sub sections will focus on solving the development on a top-down view, solving the "easiest" problems first, such as adapting the complete widgets that exist on Toga already and is used on Cricket.
Aside from modifying the main file, since the GUI is separated on an independent class named
MainWindow
, there is no need to refactor any other class when the port is complete.The average time cost to develop a widget was calculated from the time cost that the primary author from the Cricket project, Russell Keith-Magee, developed some new widget or feature to a specific platform (inferred from commits on GitHub), multiplied by 6 to estimate the time that I will take to develop.
3.2.1 Adapt the complete widgets that exist on Toga already and is used on Cricket (8.5 weeks)
3.2.1.1 Core Widgets (1.5 week)
The core widgets available on Toga are
Application
,Box
,Font
,Widget
andWindow
, but I will need to adapt only 4 of them, since the utility of the classWidgets
on Cricket will be defined later onTree
. The explanation is the following:Toga: This core widget is used to manage the main loop of the application and to control the other core widget, Window, setting the title, size and other properties of the main Window.
Tkinter: The title, geometry and other properties of the window on Tkinter also is setup on a core widget of the application, named root.
Result: This adaptation is possible.
Toga: Box is a container for any widget, so other boxes can be added inside it as well. Also, with the Colosseum integration, the style is made with a partial CSS environment.
Tkinter: The closest similar object of
Box
on this framework would be thePanedWindow
, which allows add other panes inside a bigger pane and modify the styles. TheFrame
widget is also similar.Result: This adaptation is possible.
Toga: Fonts of the labels, modify family and size.
Tkinter: Also allows to modify de family and size, but there are many other options, like, weight, underline, overstrike and slant.
Result: Since is not really necessary to add weight of label this adaptation is possible. If time permits I can add those new properties on Toga.
Toga: Base class for widgets, not instantiated directly.
Tkinter: Standard options and commands supported on all widgets. This module is used on Cricket as a event handler when a test case has been selected in the tree.
Result: These event handler explained above will be develop on another widget,
Tree
. So the adaptation will be made later.Toga: Display components to the user, support displaying multiple widgets, toolbars and resizing.
Tkinter: The class more similar to
Window
is theFrame
together with the main classTk
. Then you can set the title on root window, add multiple widgets, toolbar and also resize.Result: This adaptation is possible.
3.2.1.2 General Widgets (5.5 weeks)
The general widgets available on Toga are
Button
,Image View
,Label
,Multiline Text Input
,Number Input
,Option Container
,Progress Bar
,Selection
,Text Input
,Table
andTree
, but I'll need adapt only 6 of them. I propose work on 2 widgets per week. The widgets that were cut off from adaptation are the following:Toga: Container for an image to be rendered on the display.
Tkinter: Cricket doesn't use this feature.
Result: There is no need to adapt this widget.
Toga: Similar to the text input but designed for larger inputs, similar to the text area field of HTML.
Tkinter: Cricket doesn't use this feature.
Result: There is no need to adapt this widget.
Toga: Text input box that is limited to numeric input.
Tkinter: Similar to this class there is
Entry
, but it is a editable text field widget, not only for number. We'll adapt this kind of widget onText Input
.Result: There is no need to adapt this widget.
Toga: A simple control for allowing the user to choose between a list of string options.
Tkinter: The class similar to this widget is
OptionMenu
, but Cricket doesn't use it.Result: There is no need to adapt this widget.
Toga: Display tabular data. It can be instantiated with the list of headings and then data rows can be added.
Tkinter: Doesn't exist this widget on Tkinter.
Result: There is no need to adapt this widget.
3.2.1.2.1 Basic General Widgets (1.5 week)
Toga: Basic clickable button. It's possible to modify the label, event on press, state of disable or enable.
Tkinter: On Cricket the button of Tk is used with the same features that the button on Toga offers.
Result: This adaptation is possible.
Toga:
Switch
implements the basics features of the widget thatTkinter
has.Tkinter: They call this feature on
Tkinter
asCheckbutton
.Result: Probably will need some improvements, like commands and variables to
Switch
, but the basic adaptation is possible.Toga: A text-label for annotating forms or interfaces.
Tkinter: On Cricket the label of Tk is used with the same features that the label on Toga offers.
Result: This adaptation is possible.
3.2.1.2.2 Intermediate General Widgets (1 week)
Toga: A simple input field for user entry of text data.
Tkinter: On Tkinter this widget will have 2 utilities, first to substitute
Entry
and secondReadOnlyText
because there is aset_readonly
method.Result: This adaptation is possible.
Toga: Simple widget for showing a percentage progress for task completion.
Tkinter: The important properties of
Progress Bar
are to set the value and the max to go. There are other properties that this widget have in addition on Tkinter, for example, length, orientation and mode.Result: The basic implementation of this widget on Toga are enough to adapt on Cricket even without those properties that Tkinter has in advance.
3.2.1.2.3 Advance General Widgets (3 week)
Toga: Is a user-selection control for choosing from a pre-configured list of controls, like a tab view.
Tkinter: There is the class for this on Tkinter, the
Notebook
, that is a multi-paned container widget.Result: The object of Tkinter is used on Cricket with the same properties that are available on Toga, so this adaptation is possible.
Toga: A scrollable display of heirarchical data.
Tkinter: Hierarchical multicolumn data display widget.
Result: This adaptation is possible.
3.2.1.3 Layout Widgets (1.5 week)
The layout widgets available on Toga are
Scroll Container
,Split Container
andWeb View
, but I will need adapt only 2 of them. The explanation is the following:Toga: Similar to the iframe or scrollable div element in HTML, it contains an object with its own scrollable selection.
Tkinter: Control the viewport of a scrollable widget.
Result: The final use of these two widget are the same, but the difference is that on Toga you add content on a scroll container and on Tkinter you add a scroll bar on a container, so this adaptation is possible.
Toga: Is a container with a movable split and the option for 2 or 3 elements.
Tkinter: There is no similar widget on Tkinter like
Split Container
but on Cricket are simulate using two separatedFrames
.Result: This adaptation is possible.
Toga: Displaying an embedded browser window within an application.
Tkinter: Cricket doesn't use this feature.
Result: There is no need to adapt this widget.
3.2.2 Finishing port (0.5 week)
3.3 Usage documentation -- last milestone (2 weeks)
(From August 8 until August 21)
On the tutorials are presented four basic tutorials of the current widgets and its features, but since we are going to add some new small modifications, it would be interesting to show their usage. For example, the new feature of enable/disable a button.
3.3.1 Add new tutorials with new features for Toga (1 week)
There are few widgets present on Toga but there are no basics examples on how to use them, so I will include a basic example of each new widgets that I'll develop on 3.2.1. For example, the widget to add menu and menu items proposed on 3.2.1.
If possible, I will add a tutorial for the other widgets that still lack a basic usage example.
3.4 If time permits...
There are some TODOs on Cricket, like improving GUI interface, including keyboard shortcuts and search, so, if time permits I will follow this sequence.
4 About me
My name is Dayanne Fernandes da Cunha, I'm an undergraduate student of Bachelor on Computer Science at University of Brasília (UnB), Brazil. My time zone is UTC-3. I program in Python for at least 3 years, I program also in C, C++, Java and Javascript. This is my very first experience on contribution for a open source project. I've already made 2 PR this month and I loved it!
Edit: The subsection
Improvement of simple widgets on Toga (0.5 week)
was removed because theSwitch
widget does what theCheckButton
do. So theSwitch
was add on theGeneral Widgets
section, intoBasic General Widgets
, bellow theButton
port. Also, the '0.5 week' was migrate to theBasic General Widgets
subsection.Edit2: The subsection
Development of objects that exist on Cricket but still not implement on Toga (2 weeks)
was removed because theMenu
builder was add on the commit beeware/toga@9d9c911. The weeks remaining from this section removal was migrate toAdvance General Widgets
subsection.The text was updated successfully, but these errors were encountered: