Help fo WindowXMLDialog and WindowXML
#1
Hi

I would like to modified DialogOK.xml to DialogWarning.xml and DialogError.xml. I've created xml files (add warning and error icon), but I have no idea how connect it to python code.

The DialogWarning.xml:

Code:
<window>
    <defaultcontrol always="true">10</defaultcontrol>
    <coordinates>
        <system>1</system>
        <posx>335</posx>
        <posy>230</posy>
    </coordinates>
    <!--<include>dialogeffect</include>-->
    <controls>
        <control type="image">
            <posx>0</posx>
            <posy>0</posy>
            <width>610</width>
            <height>240</height>
            <texture border="40">DialogBack.png</texture>
        </control>
        <control type="image">
            <description>Dialog Header image</description>
            <posx>40</posx>
            <posy>16</posy>
            <width>530</width>
            <height>40</height>
            <texture>dialogheader.png</texture>
        </control>
        <control type="image">
            <description>Dialog Warning image</description>
            <posx>40</posx>
            <posy>80</posy>
            <width>64</width>
            <height>64</height>
            <texture>DefaultIconWarning.png</texture>
        </control>
        <control type="label" id="1">
            <description>header label</description>
            <posx>40</posx>
            <posy>20</posy>
            <width>530</width>
            <height>30</height>
            <font>font13_title</font>
            <!--<label>$LOCALIZE[13406]</label>-->
            <label></label>
            <align>center</align>
            <aligny>center</aligny>
            <textcolor>selected</textcolor>
            <shadowcolor>black</shadowcolor>
        </control>
        <control type="button">
            <description>Close Window button</description>
            <posx>520</posx>
            <posy>15</posy>
            <width>64</width>
            <height>32</height>
            <label>-</label>
            <font>-</font>
            <onclick>PreviousMenu</onclick>
            <texturefocus>DialogCloseButton-focus.png</texturefocus>
            <texturenofocus>DialogCloseButton.png</texturenofocus>
            <onleft>10</onleft>
            <onright>10</onright>
            <onup>10</onup>
            <ondown>10</ondown>
            <visible>system.getbool(input.enablemouse)</visible>
        </control>
        <control type="label" id="2">
            <description>dialog line 1</description>
            <posx>120</posx>
            <posy>60</posy>
            <width>550</width>
            <height>30</height>
            <align>left</align>
            <aligny>center</aligny>
            <label>-</label>
            <font>font13</font>
        </control>
        <control type="label" id="3">
            <description>dialog line 2</description>
            <posx>120</posx>
            <posy>85</posy>
            <width>550</width>
            <height>30</height>
            <align>left</align>
            <aligny>center</aligny>
            <label>-</label>
            <font>font13</font>
        </control>
        <control type="label" id="4">
            <description>dialog line 3</description>
            <posx>120</posx>
            <posy>110</posy>
            <width>550</width>
            <height>30</height>
            <align>left</align>
            <aligny>center</aligny>
            <label>-</label>
            <font>font13</font>
        </control>
        <control type="button" id="10">
            <description>OK button</description>
            <posx>205</posx>
            <posy>175</posy>
            <width>200</width>
            <height>40</height>
            <label>186</label>
            <font>font12_title</font>
            <textcolor>white</textcolor>
            <focusedcolor>white</focusedcolor>
            <align>center</align>
            <onleft>10</onleft>
            <onright>10</onright>
            <onup>10</onup>
            <ondown>10</ondown>
        </control>
    </controls>
</window>

If you see I'm using modified DialogOK.xml (I added only icon).
The framework of window is:

Code:
class MessageDialog(xbmcgui.WindowXMLDialog):
    def __init__(self, strXMLname, strFallbackPath, strDefaultName, forceFallback = 0):
        pass
    
    def onInit(self):
       pass
    
    def onAction(self, action):
        pass
    
    def onClick(self, controlID):
        pass
    
    def onFocus(self, controlID):
        pass

Could any of you tell me how I can write a code to using this class as xbmcgui.ok("tittle", "text1", text2", text3")? I would like to use as msg.Warn("title", "text1", text2", text3").
I tried to find answer for my problem by searching of net, but I didn't find any simple examples (understanding for me) to use windowxml/windowxmldialog (get/set id).
Thanks for help

Plesken
Reply
#2
I see nobody want help me. So I have solved this problem:

The xml file (DialogError.xml):

Code:
<window>
    <defaultcontrol always="true">10</defaultcontrol>
    <zorder>10</zorder>
    <coordinates>
        <system>1</system>
        <posx>275</posx>
        <posy>230</posy>
    </coordinates>
    <controls>
        <control type="image">
            <posx>0</posx>
            <posy>0</posy>
            <width>730</width>
            <height>240</height>
            <texture border="40">DialogBack.png</texture>
        </control>
        <control type="image">
            <description>Dialog Header image</description>
            <posx>40</posx>
            <posy>16</posy>
            <width>650</width>
            <height>40</height>
            <texture>dialogheader.png</texture>
        </control>
        <control type="image">
            <description>Dialog Warning image</description>
            <posx>40</posx>
            <posy>80</posy>
            <width>64</width>
            <height>64</height>
            <texture>DefaultIconError.png</texture>
        </control>
        <control type="label" id="101">
            <description>header label</description>
            <posx>100</posx>
            <posy>20</posy>
            <width>530</width>
            <height>30</height>
            <font>font13_title</font>
            <label>-</label>
            <align>center</align>
            <aligny>center</aligny>
            <textcolor>selected</textcolor>
            <shadowcolor>black</shadowcolor>
        </control>
        <control type="button" id="111">
            <description>Close Window button</description>
            <posx>650</posx>
            <posy>15</posy>
            <width>64</width>
            <height>32</height>
            <label>-</label>
            <font>-</font>
            <onclick>PreviousMenu</onclick>
            <texturefocus>DialogCloseButton-focus.png</texturefocus>
            <texturenofocus>DialogCloseButton.png</texturenofocus>
            <onleft>110</onleft>
            <onright>110</onright>
            <onup>110</onup>
            <ondown>110</ondown>
            <visible>system.getbool(input.enablemouse)</visible>
        </control>
        <control type="label" id="102">
            <description>dialog line 1</description>
            <posx>120</posx>
            <posy>70</posy>
            <width>550</width>
            <height>30</height>
            <align>left</align>
            <aligny>center</aligny>
            <label>-</label>
            <font>font13</font>
        </control>
        <control type="label" id="103">
            <description>dialog line 2</description>
            <posx>120</posx>
            <posy>95</posy>
            <width>550</width>
            <height>30</height>
            <align>left</align>
            <aligny>center</aligny>
            <label>-</label>
            <font>font13</font>
        </control>
        <control type="label" id="104">
            <description>dialog line 3</description>
            <posx>120</posx>
            <posy>120</posy>
            <width>550</width>
            <height>30</height>
            <align>left</align>
            <aligny>center</aligny>
            <label>-</label>
            <font>font13</font>
        </control>
        <control type="button" id="110">
            <description>OK button</description>
            <posx>265</posx>
            <posy>175</posy>
            <width>200</width>
            <height>40</height>
            <label>186</label>
            <font>font12_title</font>
            <textcolor>white</textcolor>
            <focusedcolor>white</focusedcolor>
            <align>center</align>
            <onleft>110</onleft>
            <onright>110</onright>
            <onup>110</onup>
            <ondown>110</ondown>
        </control>
    </controls>
</window>

Python code:

Code:
# -*- coding: utf-8 -*-
import xbmc, xbmcgui, sys, re, os
import xbmcplugin, xbmcaddon

__scriptID__   = sys.modules[ "__main__" ].__scriptID__
t = sys.modules[ "__main__" ].__language__
__addon__ = xbmcaddon.Addon(__scriptID__)

os.path.join( __addon__.getAddonInfo('path'), "resources" )

MESSAGE_ACTION_OK = 110
MESSAGE_EXIT = 111
MESSAGE_TITLE = 101
MESSAGE_LINE1 = 102
MESSAGE_LINE2 = 103
MESSAGE_LINE3 = 104

class MessageDialog(xbmcgui.WindowXMLDialog):
    def __init__(self, strXMLname, strFallbackPath, strDefaultName, forceFallback = True):
        #print 'args: ' + str(forceFallback)
        pass
    
    def setTableText(self, tab):
        self.tabText = tab
        
    def getTableText(self):
        return self.tabText
    
    def onInit(self):
        self.getControl(MESSAGE_TITLE).setLabel(self.getTableText()['title'])
        self.getControl(MESSAGE_LINE1).setLabel(self.getTableText()['text1'])
        if self.getTableText()['text2'] != "" and self.getTableText()['text3'] != "":
            self.getControl(MESSAGE_LINE2).setLabel(self.getTableText()['text2'])
            self.getControl(MESSAGE_LINE3).setLabel(self.getTableText()['text3'])
        #pass
    
    def onAction(self, action):
        if action == 1010:
            self.close()
    
    def onClick(self, controlID):
        if controlID == MESSAGE_ACTION_OK or controlID == MESSAGE_EXIT:
            self.onAction(1010)
    
    def onFocus(self, controlID):
        pass
    
    
class Windows:
    def __init__(self):
        pass
    
    def Warning(self, title, text1, text2 = "", text3 = ""):
        msg = MessageDialog("DialogWarning.xml", __addon__.getAddonInfo('path'), "Default")
        tabText = { 'title': title, 'text1': text1, 'text2': text2, 'text3': text3 }
        msg.setTableText(tabText)
        msg.doModal()
        del msg
        
    def Error(self, title, text1, text2 = "", text3 = ""):
        msg = MessageDialog("DialogError.xml", __addon__.getAddonInfo('path'), "Default")
        tabText = { 'title': title, 'text1': text1, 'text2': text2, 'text3': text3 }
        msg.setTableText(tabText)
        msg.doModal()
        del msg

I think it will be usefull for people Smile

Plesken
Reply
#3
Nice work.. Why not build this into a script.module and submit it to the Official repo. This would allow more users to access it.
Reply
#4
giftie Wrote:Nice work.. Why not build this into a script.module and submit it to the Official repo. This would allow more users to access it.

I'm writting plugin and I needed warn and error dialogs Smile. You are right. These dialogs should be added to official repo, so I will write script soon.
Reply

Logout Mark Read Team Forum Stats Members Help
Help fo WindowXMLDialog and WindowXML0