TextBox control alignment - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: TextBox control alignment (/showthread.php?tid=189876) Pages:
1
2
|
TextBox control alignment - Anthirian - 2014-03-21 Hi, for my addon XBMC File Cleaner I am currently writing a log viewer that is activated through the addon's settings. In the Artwork Downloader addon I have found something very similar, which I've tailored to my needs. I do however have one issue with the alignment of the text. I'm logging the filenames of any files that get cleaned up and these filenames can be quite long. When using scene names with XBMC, filenames tend to have periods instead of spaces, causing the (default?) justification alignment to mess up the text. I use the method below in order to set the text in the TextBoxControl. I looked in the documentation but cannot find methods named "setAlign()" or "setProperty('align', 'left')". As you can see in the attached screenshots, alignment is definitely needed. I added some long lines from the XBMC logfile to better show the issue. PHP Code: __title__ = "XBMC File Cleaner" Since I know very little about skinning, I don't know how to align the text differently. I noticed from the log files that DialogTextViewer.xml is loaded once the window is activated. I then tried modifying it as below, but it appears to be skin-dependent. PHP Code: <control type="textbox" id="5"> Could someone please help me find a universal way to left-align the text in this particular TextBox only? I don't want to mess up other people's skins just to print one simple log file nicely. On the other hand, if I could tell XBMC to allow wrapping on other characters like dashes, semicolons, colons, periods or comma's that would also be a big help. watch gallery
RE: TextBox control alignment - ruuk - 2014-03-21 I would say your best bet is to create your own dialog skin and display it using that. RE: TextBox control alignment - Anthirian - 2014-03-23 There is no option to set extra characters to allow hyphenation for? If not, how would I go about making my own textbox? Do I need to follow the skinning manuals? Re: RE: TextBox control alignment - ruuk - 2014-03-23 (2014-03-23, 11:23)Anthirian Wrote: There is no option to set extra characters to allow hyphenation for? If not, how would I go about making my own textbox? Do I need to follow the skinning manuals?No there is not an option like that. The skinning manual has what you need to design the skin. You will also need to display it with the xbmcgui module. When I'm not on my phone at work though, I can post some instructions and an example. RE: TextBox control alignment - ruuk - 2014-03-23 Here's the basic xml for a simple dialog with a textbox. I haven't tested it so some of the positioning may need some tweaking. Code: <?xml version="1.0" encoding="utf-8" standalone="yes"?> You put this in <addon_dir>/resources/skins/<skin_name>/720p/ So if we call this skin 'Example' we could save it as <addon_dir>/resources/skins/Example/720p/example-text-dialog.xml For this example you would also need to save the following to <addon_dir>/resources/skins/Example/skin.xml Code: <?xml version="1.0" encoding="utf-8" standalone="yes"?> In this example there are three images. One for the background and two for the scrollbar. Put those in <addon_dir>/resources/skins/Example/media/ And that covers the skin itself. To display this you could use the following code: Code: import xbmcgui, xbmcaddon And I think that about covers the basics. RE: TextBox control alignment - Anthirian - 2014-03-23 Thank you very much for this detailed explanation. I'll give it a try this week. RE: TextBox control alignment - Anthirian - 2014-03-24 I followed your instructions to the letter, but it looks like I'm having some issues getting the window to actually focus. I'm calling it via the settings using the following XML: PHP Code: <setting label="32602" type="action" action="RunScript($CWD/viewer.py)" /> Using this, the window seems to be created, because only after I hit the back button can I select other settings. What am I doing wrong? The log is below. The only thing out of the ordinary seems the fact that the list of ParentPaths is empty. Is that normal? Code: 20:10:51 T:11252 DEBUG: XBPyThread::Process - The source file to load is C:\Users\Geert\AppData\Roaming\XBMC\addons\script.filecleaner/viewer.py RE: TextBox control alignment - ruuk - 2014-03-24 (2014-03-24, 21:17)Anthirian Wrote: I followed your instructions to the letter, but it looks like I'm having some issues getting the window to actually focus. I'm calling it via the settings using the following XML: It sounds like the window is displaying under the settings window. Try inserting <zorder>2</zorder> in the windows xml file like below: Code: <window> RE: TextBox control alignment - Anthirian - 2014-03-24 Yes, that solved the issue. Thank you once again. I can now start skinning RE: TextBox control alignment - Anthirian - 2014-03-29 Okay, I've spent a few days getting a nice window with a caption, a textbox, a scrollbar and a few buttons in it. In the textbox I am showing the contents of a text file (log) and I allow the user to either clear or trim the log using the two buttons in the window. As such, I currently call the same script that shows the window but with a different argument, as below. Code: <onclick>XBMC.RunScript(special://home/addons/script.filecleaner/viewer.py, trim)</onclick> Now, this all works quite well, but it always creates a new window over the existing one. I prefer reusing the existing window, but since it's not a built-in window I'm having trouble with it. I have tried setting <id> tags in my WindowXML file, e.g. 13000 (outside the reserved IDs), but I can't seem to use that instead of creating a new window. How do I make viewer.py use the already opened window that the button is pressed in? RE: TextBox control alignment - ruuk - 2014-03-29 Give the buttons id attributes and add this to your window class and use it and instead: Code: def onClick(self,controlID): In doTrim() you would modify the text and re-display it just as you did in onInit() RE: TextBox control alignment - Anthirian - 2014-03-29 Aha, so it's the other way around. Don't do the callback in the XML file but in the Python script. I changed it and it works like a charm, thanks! One last question though: I would like to increase the caption's font size, but does that really require me to include my own font files and Font.xml? I would simply like to use existing fonts, but larger. Is this possible? RE: TextBox control alignment - ruuk - 2014-03-29 You can't include your own font files, even if you want to (other than modifying the XBMC skin). You can use a larger font from the skin, but if the skin the person is using is different, it may just use the default font size. One method to deal with this is to create different xml files for different skins and detect the skin and change xml based on that. But that only works for skins you include specific files for. The other way I have used is to read in the current skins Font.xml file and attempt to find the closest match in font size and then modify your skin file on the fly with those font names. Both of these methods are overly complex for one dialog, so I would just make do with the default font size. RE: TextBox control alignment - Anthirian - 2014-04-02 I must have missed your response since it was so quick. Thanks for the explanation, I have indeed decided to just use the default font size. Instead of increasing the size I just changed the text color. Thanks for all the help! RE: TextBox control alignment - ruuk - 2014-04-04 I forgot to mention. For creating line breaks at other characters than spaces, you could try inserting an empty formatting tag after the character. For instance replace Code: 'filename-1x01.mp4' Code: 'filename-[B][/B]1x01.mp4' |