<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.slicer.org/w/index.php?action=history&amp;feed=atom&amp;title=Documentation%2F4.2%2FDevelopers%2FTutorials%2FPythonAndUIFile</id>
	<title>Documentation/4.2/Developers/Tutorials/PythonAndUIFile - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.slicer.org/w/index.php?action=history&amp;feed=atom&amp;title=Documentation%2F4.2%2FDevelopers%2FTutorials%2FPythonAndUIFile"/>
	<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Tutorials/PythonAndUIFile&amp;action=history"/>
	<updated>2026-04-06T22:57:17Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Tutorials/PythonAndUIFile&amp;diff=32822&amp;oldid=prev</id>
		<title>UpdateBot: Prepend documentation/versioncheck template. See http://na-mic.org/Mantis/view.php?id=2887</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Tutorials/PythonAndUIFile&amp;diff=32822&amp;oldid=prev"/>
		<updated>2013-06-14T07:46:48Z</updated>

		<summary type="html">&lt;p&gt;Prepend documentation/versioncheck template. See http://na-mic.org/Mantis/view.php?id=2887&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 07:46, 14 June 2013&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Back to [[Documentation/{{documentation/version}}/Developers|Developers Information]]&amp;amp;larr;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Back to [[Documentation/{{documentation/version}}/Developers|Developers Information]]&amp;amp;larr;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>UpdateBot</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Tutorials/PythonAndUIFile&amp;diff=28615&amp;oldid=prev</id>
		<title>UpdateBot: Nightly -&gt; 4.2</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/Tutorials/PythonAndUIFile&amp;diff=28615&amp;oldid=prev"/>
		<updated>2012-10-31T21:55:44Z</updated>

		<summary type="html">&lt;p&gt;Nightly -&amp;gt; 4.2&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Back to [[Documentation/{{documentation/version}}/Developers|Developers Information]]&amp;amp;larr;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial will demonstrate how UI file created using QtDesigner can be loaded and used from a python script loaded using the Slicer python interactor.&lt;br /&gt;
&lt;br /&gt;
As depicted below, let's assume you created a UI file where a QLineEdit and QPushButton are layout horizontally.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:UIFileForPythonExample.png|thumb|600px|Example of UI file with a QPushButton and QLineEdit]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Loading the UI file and accessing the associated objects can be done using [http://doc.trolltech.com/4.7/quiloader.html QUILoader]. &lt;br /&gt;
&lt;br /&gt;
The following code snippet aims at loading the UI file and connecting the associated QPushButton and QLineEdit.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Load UI file&lt;br /&gt;
uiloader = qt.QUiLoader()&lt;br /&gt;
file = qt.QFile(&amp;quot;/home/jchris/Projects/sandbox/qSlicerLineEditWidget.ui&amp;quot;)&lt;br /&gt;
file.open(qt.QFile.ReadOnly)&lt;br /&gt;
line_edit_widget = uiloader.load(file)&lt;br /&gt;
file.close()&lt;br /&gt;
&lt;br /&gt;
# Get references to both the QPushButton and the QLineEdit&lt;br /&gt;
clear_button = line_edit_widget.findChild(qt.QPushButton, 'ClearButton')&lt;br /&gt;
line_edit = line_edit_widget.findChild(qt.QLineEdit, 'LineEdit')&lt;br /&gt;
&lt;br /&gt;
clear_button.connect('clicked()', line_edit, 'clear()')&lt;br /&gt;
&lt;br /&gt;
line_edit_widget.show() &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Idea of possible improvements ==&lt;br /&gt;
* Instead of obtaining the reference using findChild, it use an helper (to be named properly) to ease the access to members.&lt;br /&gt;
For example: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
line_edit_widget = HELPER(uiloader.load(file))&lt;br /&gt;
line_edit_widget.ClearButton.connect('clicked()', line_edit_widget.LineEdit, 'clear()')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or how about &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
designedFile = HELPER(fileName.ui)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>UpdateBot</name></author>
		
	</entry>
</feed>