-
-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added helper method to avoid call get_variable for every variable. refs
- Loading branch information
1 parent
e7fbf82
commit 149724a
Showing
3 changed files
with
101 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# encoding: utf8 | ||
import os | ||
import sys | ||
import unittest | ||
try: | ||
import tkinter as tk | ||
import tkinter.ttk as ttk | ||
except: | ||
import Tkinter as tk | ||
import ttk | ||
|
||
|
||
pygubu_basedir = os.path.abspath(os.path.dirname( | ||
os.path.dirname(os.path.realpath(sys.argv[0])))) | ||
if pygubu_basedir not in sys.path: | ||
sys.path.insert(0, pygubu_basedir) | ||
|
||
import pygubu | ||
import support | ||
|
||
|
||
class MyContainer(object): | ||
pass | ||
|
||
|
||
class TestText(unittest.TestCase): | ||
|
||
def setUp(self): | ||
support.root_deiconify() | ||
xmldata = 'test_import_variables.ui' | ||
self.builder = builder = pygubu.Builder() | ||
builder.add_from_file(xmldata) | ||
self.widget = builder.get_object('mainwindow') | ||
|
||
def tearDown(self): | ||
support.root_withdraw() | ||
|
||
def test_import_variables(self): | ||
container = MyContainer() | ||
self.builder.import_variables(container) | ||
self.assertIsInstance(container.myvar_string, tk.StringVar) | ||
self.assertIsInstance(container.myvar_int, tk.IntVar) | ||
self.assertIsInstance(container.myvar_double, tk.DoubleVar) | ||
self.assertIsInstance(container.myvar_boolean, tk.BooleanVar) |
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,52 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<interface> | ||
<object class="ttk.Frame" id="mainwindow"> | ||
<property name="height">200</property> | ||
<property name="width">200</property> | ||
<layout> | ||
<property name="column">0</property> | ||
<property name="propagate">True</property> | ||
<property name="row">0</property> | ||
</layout> | ||
<child> | ||
<object class="ttk.Entry" id="Entry_1"> | ||
<property name="textvariable">string:myvar_string</property> | ||
<layout> | ||
<property name="column">0</property> | ||
<property name="propagate">True</property> | ||
<property name="row">0</property> | ||
</layout> | ||
</object> | ||
</child> | ||
<child> | ||
<object class="ttk.Entry" id="Entry_2"> | ||
<property name="textvariable">int:myvar_int</property> | ||
<layout> | ||
<property name="column">0</property> | ||
<property name="propagate">True</property> | ||
<property name="row">1</property> | ||
</layout> | ||
</object> | ||
</child> | ||
<child> | ||
<object class="ttk.Entry" id="Entry_3"> | ||
<property name="textvariable">double:myvar_double</property> | ||
<layout> | ||
<property name="column">0</property> | ||
<property name="propagate">True</property> | ||
<property name="row">2</property> | ||
</layout> | ||
</object> | ||
</child> | ||
<child> | ||
<object class="ttk.Entry" id="Entry_4"> | ||
<property name="textvariable">boolean:myvar_boolean</property> | ||
<layout> | ||
<property name="column">0</property> | ||
<property name="propagate">True</property> | ||
<property name="row">3</property> | ||
</layout> | ||
</object> | ||
</child> | ||
</object> | ||
</interface> |