You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/guide/firststeps.rst
+22-24Lines changed: 22 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,23 +5,23 @@ First steps
5
5
6
6
To define your first object parameters with TkClassWizard, you can create
7
7
a :class:`tkinter.TopLevel` inherited object :class:`~tkclasswiz.object_frame.window.ObjectEditWindow` and then
8
-
call its :py:meth:`~tkclasswiz.object_frame.window.ObjectEditWindow.open_object_edit_frame` method, which
9
-
will open up the window and then load in :class:`tkinter.Frame`, which will contain placeholders for all parameter
8
+
call its :py:meth:`~tkclasswiz.object_frame.window.ObjectEditWindow.open_object_edit_frame` method. This
9
+
will open up the window and then load :class:`tkinter.Frame`, which will contain placeholders for all the parameter
10
10
values.
11
11
12
12
The :py:meth:`~tkclasswiz.object_frame.window.ObjectEditWindow.open_object_edit_frame` method accepts the following
13
13
parameters:
14
14
15
-
- class\ _: This is the class or a function that we want the parameters for.
15
+
- class\ _: This is the class or function that will accept our given parameters.
16
16
- return_widget: This is a widget that receives the value after saving the newly defined parameters.
17
-
- old_data: The old_data gui data.
18
-
- check_parameters: Boolean parameter, which if Truewill not test if the object parameters are correct. When
17
+
- old_data: The old_data GUI data.
18
+
- check_parameters: Boolean parameter. If True, it will not test whether the object parameters are correct. When
19
19
editing a function this is not ignored.
20
-
- allow_save: Boolean parameter, which if Falsewill prevent the defined data to be saved; This also means it will
20
+
- allow_save: Boolean parameter. If False, it will not allow the defined data to be saved; This also means it will
21
21
be read-only.
22
22
23
23
24
-
It's best we take a look at an example.
24
+
Let's take a look at an example.
25
25
26
26
.. code-block:: python
27
27
:linenos:
@@ -72,40 +72,38 @@ It's best we take a look at an example.
72
72
73
73
74
74
75
-
In the above example we first import the library by typing ``import tkclasswiz as wiz``.
75
+
In this example we first import the library by typing ``import tkclasswiz as wiz``.
76
76
Then we define 2 classes, the class ``Wheel`` and class ``Car``.
77
77
78
78
The ``Wheel`` class accepts a single parameter annotated with the ``float`` type. It is VERY IMPORTANT
79
-
that all the parameters are annotated, else they will not be displayed when defining parameters through the GUI.
79
+
that all the parameters are annotated. Otherwise they will not be displayed when defining parameters through the GUI.
80
80
81
-
The ``Car`` class accepts parameters ``name`` of type ``str``, ``speed`` of type ``float`` and list of ``wheels``
82
-
of type ``Wheel``. From the ``wheels`` parameter we can see that we can define multiple nested objects as well.
81
+
The ``Car`` class accepts the following parameters: ``name`` of type ``str``, ``speed`` of type ``float`` and a list of ``wheels``
82
+
of type ``Wheel``. The ``wheels`` parameter allows us to define multiple nested objects as well.
83
83
84
84
Then we create an instance of ``Tk``, which is just the standard way for creating a tkinter app.
85
85
86
-
Then we create a ``combo`` variable of type :class:`~tkclasswiz.storage.ComboBoxObjects`, which will receive the defined
87
-
``Car`` object after we define the object successfully. But it won't receive an actual instance of ``Car``,
88
-
however it will receive an abstract representation of the defined object. The abstract representation is an instance of
89
-
:class:`tkclasswiz.convert.ObjectInfo` and its job is to store the class (in our case ``Car``) and the parameters
90
-
defined. When displaying the defined abstract ``Car`` object inside the GUI, it will be displayed as
86
+
After that, we create a ``combo`` variable of type :class:`~tkclasswiz.storage.ComboBoxObjects`, which will receive the
87
+
``Car`` object after it is defined successfully. However, it won't receive an actual instance of ``Car``. Instead, it will receive an abstract representation of the defined object. The abstract representation is an instance of
88
+
:class:`tkclasswiz.convert.ObjectInfo` and its job is to store the class (in our case ``Car``) and the defined parameters. When displaying the defined abstract ``Car`` object inside the GUI, it will be displayed as
91
89
``Class(parameter1=value1, ...)``.
92
90
93
-
Afterwards we define 2 functions, the first one will open the definition window, while the second one will
91
+
We then define 2 functions. The first one will open the definition window, while the second one will
94
92
convert the abstract ``Car`` object into a real Python object.
95
93
96
-
Function ``make_car`` accepts a parameter ``old``, which will be later used to edit the existing object after we defined it.
97
-
But since it is not defined yet, this is currently irrelevant. Next lines of code in the function create the
94
+
The function ``make_car`` accepts a parameter ``old``, which will be used to edit the existing object after we defined it at a later point.
95
+
However, since it is not currently defined, it has no effect. The next lines of code in the function create the
98
96
:class:`~tkclasswiz.object_frame.window.ObjectEditWindow` definition window and load in the definition frame by calling
99
-
the :py:meth:`~tkclasswiz.object_frame.window.ObjectEditWindow.open_object_edit_frame`, which we pass
100
-
the class of an object we want to define (``Car``), the return widget (``combo``) that receives the defined object and
97
+
the :py:meth:`~tkclasswiz.object_frame.window.ObjectEditWindow.open_object_edit_frame`. With this method, we can pass
98
+
the class of an object we want to define (``Car``), the return widget (``combo``) that receives the defined object, and
101
99
the ``old_data`` parameter which would load in previously defined values (which currently don't exist).
102
100
103
101
At the very bottom of the example, we define a few buttons:
0 commit comments