{"id":102,"date":"2009-09-17T10:03:27","date_gmt":"2009-09-17T11:03:27","guid":{"rendered":"http:\/\/www.tamats.com\/blog\/?p=102"},"modified":"2009-09-17T10:07:44","modified_gmt":"2009-09-17T11:07:44","slug":"hackpact-day-9-text-and-widgets","status":"publish","type":"post","link":"https:\/\/www.tamats.com\/blog\/?p=102","title":{"rendered":"Hackpact Day 9: Text and Widgets"},"content":{"rendered":"<p>I think I totally have lost the path in this project. I wanted to experiment more about different ideas and instead I&#8217;m building a full application, which somehow is good because I&#8217;m touching all the fields of python, but I miss to have more crazy ideas.<\/p>\n<p>So I don&#8217;t know what will I do next, I think that the current version of Pyncel is enought powerful to do interesting things. Btw, the name comes from pincel (brush in spanish) and python.<\/p>\n<p>I want to do experiments with automated brushes, for that purpose I will create a XML file document where I will write all the info, the textures filenames involved, the preassure, and more settings. But not just that, Im planning to put a little bit of source code in the XML, so when you load a brush you can add some automations.<\/p>\n<p>Today I&#8217;m going to put the source code of the latest version. It is growing fast so now there are a lot of files, but they are well defined so it is easy to understand.<\/p>\n<p>There is only one new module required, WxWidgets. I added it because I wanted to have some dialogs for loading or saving files, and I thought it would be stupid to code them by myself. But it doesnt mean all the app runs on Wx now, I just created a tiny WxApp that is created when you need the dialog, and destroyed afterwards, and it works perfectly for what I need.<\/p>\n<p>Here is the source code to have a FileDialog:<\/p>\n<blockquote><p>def ChooseFileDialog(caption=&#8221;Choose a file&#8221;,folder=&#8221;C:\/&#8221;,default=&#8221;file.png&#8221;,wildcard=&#8221;*.png&#8221;):<\/p>\n<p style=\"padding-left: 30px;\">class SAPPWX(wx.Frame):<\/p>\n<p style=\"padding-left: 60px;\">myfile=&#8221;&#8221;<br \/>\ndef __init__(self,parent,id,title):<\/p>\n<p style=\"padding-left: 90px;\">wx.Frame.__init__(self,parent,id,title)<br \/>\nself.initialize()<\/p>\n<p style=\"padding-left: 60px;\">def initialize(self):<\/p>\n<p style=\"padding-left: 90px;\">dlg = wx.FileDialog(self, caption, folder, default, wildcard, wx.FD_SAVE)<br \/>\nif dlg.ShowModal() == wx.ID_OK:<br \/>\nSAPPWX.myfile = dlg.GetPath()<br \/>\nself.Destroy()<\/p>\n<p style=\"padding-left: 30px;\">app = wx.PySimpleApp()<br \/>\nframe = SAPPWX(None,-1,&#8221;)<br \/>\napp.MainLoop()<\/p>\n<p style=\"padding-left: 30px;\">return SAPPWX.myfile<\/p>\n<\/blockquote>\n<p>I though it was interesting to have such a freedom to create a GUI element without having to deal with all the application stuff. Maybe there is a better way to do this but I didnt found it. I am concerned that maybe the wx app is still running in the background&#8230;<\/p>\n<p>I also wanted to render a little HUD but I know from previous work how hard it is to draw text on a OpenGL application, so I just used the GLUT options to raster text, it is slow and ugly, but it is just 3 lines of code without addind more dependencies. The only problem is that it doesnt allow you to change the font-size, but I don&#8217;t care.<\/p>\n<p>So here it is the source code: <a href=\"http:\/\/www.tamats.com\/blog\/wp-content\/uploads\/2009\/09\/hackpact-day-9.zip\">hackpact day 9<\/a><\/p>\n<p>And some random screenshots made with the latest version:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-104\" title=\"nebula\" src=\"http:\/\/www.tamats.com\/blog\/wp-content\/uploads\/2009\/09\/nebula.jpg\" alt=\"nebula\" width=\"550\" height=\"550\" srcset=\"https:\/\/www.tamats.com\/blog\/wp-content\/uploads\/2009\/09\/nebula.jpg 550w, https:\/\/www.tamats.com\/blog\/wp-content\/uploads\/2009\/09\/nebula-150x150.jpg 150w, https:\/\/www.tamats.com\/blog\/wp-content\/uploads\/2009\/09\/nebula-300x300.jpg 300w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-105\" title=\"nebula2\" src=\"http:\/\/www.tamats.com\/blog\/wp-content\/uploads\/2009\/09\/nebula2.jpg\" alt=\"nebula2\" width=\"550\" height=\"550\" srcset=\"https:\/\/www.tamats.com\/blog\/wp-content\/uploads\/2009\/09\/nebula2.jpg 550w, https:\/\/www.tamats.com\/blog\/wp-content\/uploads\/2009\/09\/nebula2-150x150.jpg 150w, https:\/\/www.tamats.com\/blog\/wp-content\/uploads\/2009\/09\/nebula2-300x300.jpg 300w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I think I totally have lost the path in this project. I wanted to experiment more about different ideas and instead I&#8217;m building a full application, which somehow is good because I&#8217;m touching all the fields of python, but I miss to have more crazy ideas. So I don&#8217;t know what will I do next, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[5,14,15],"class_list":["post-102","post","type-post","status-publish","format-standard","hentry","category-devlog","tag-opengl","tag-pythoh","tag-wxwidgets"],"_links":{"self":[{"href":"https:\/\/www.tamats.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tamats.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tamats.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tamats.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tamats.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=102"}],"version-history":[{"count":4,"href":"https:\/\/www.tamats.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions"}],"predecessor-version":[{"id":109,"href":"https:\/\/www.tamats.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions\/109"}],"wp:attachment":[{"href":"https:\/\/www.tamats.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tamats.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tamats.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}