Tagged: eclipse Toggle Comment Threads | Keyboard Shortcuts

  • hardikmehta 9:02 pm on August 13, 2009 Permalink | Reply
    Tags: , eclipse, forecast, , , , plasmoid, pydev, pykde4, pyqt4, Python, python-plasmoid, qt4, ,   

    A weather plasmoid in python 

    Ever since I heard about plasma I was eager to find ways to write my own plasmoid. But for the development of binary plasmoids, it is necessary to compile at least a part of kde4, at least this is what I understood from the prerequisite listed on the official tutorial. This discouraged me a bit. Moreover, I think that installation of the binary gadgets also requires to either package them properly according to the distribution you want to distribute for or you need to provide the sources that requires the users to build them. This  in my opinion is really a huge overhead for small applications like desktop gadgets / widgets. Then I found that it is also possible to develop plasmoids with script languages like python, ruby and javascript.

    Even though, I didn’t know PyQT4 or PyKDE4 libraries at all, I decided to write my first plasmoid in python.  This is an exremely simple plasmoid, the core of which was put together in a few hours on a rainy weekend. I have to admit that being a java developer, my code is not pythonic enough.

    It can be downloaded from: kde-look.

    Here the source code: plasma_pyweather.

    wplasmoid_greytransThe layout is based on my conky setup described here. I have tried to keep it as compact as possible including most of the provided information, if not all.  I don’t want the weather information to cover most of the screen.  The initial version of the plasmoid was written using the QT4 widgets, but was looking ugly.

    The weather information is fetched from google weather api. The location and the unit are configurable. The api provides forecast only for the next 3 days, so the number of forecast days were not made configurable.  Some how for google weather api the locale and so the unit is connected to the language, therefor  I had to convert the units myself. To keep the display compact I rounded the temperatures to integers.

    I got to learn PyQT4 and PyKDE4 libraries while writing this. Especially PyQT4 is a very powerful gui library for python.  It is fun programming with it. I have used eclipse + pydev for developing. In the beginning I didn’t have the auto-completion for PyQT4 as well as PyKDE4 in this environment, because they are not installed as pure python source code files. I could fix this with following answer.

    The other interesting things, I learned was to use the qt-designer tool for creating gui. It is a nice WYSIWYG tool for designing complex guis. The configuration form is designed using this tool. The qt-designer creates a .ui file, which is an xml file. The .ui file can be converted to the python source code using the pyuic4 tool in the following way.

    pyuic4 -o configForm_ui.py ../ui/configForm.ui
    

    I also learned to use the .qrc file for resources like images. The .qrc file can be converted into python source code using  pyrcc4 tool

    pyrcc4 -o images_rc.py images.qrc
    

    The qrc file is also an xml file which contains the references to the images used. It can be created by just editing.

    <RCC>
        <qresource prefix="/images">
            <file alias="sunny.svgz">../images/sunny.svgz</file>
            <file alias="showers.svgz">../images/showers.svgz</file>
            <file alias="not-available.svgz">../images/not-available.svgz</file>
            <file alias="cloudy.svgz">../images/cloudy.svgz</file>
            <file alias="thunderstorms.svgz">../images/thunderstorms.svgz</file>
            <file alias="haze.svgz">../images/haze.svgz</file>
            <file alias="windy.svgz">../images/windy.svgz</file>
        </qresource>
    </RCC>
    

    I decided to write this weather plasmoid in python, because all the other weather plasmoids I found were binaries. I have also tried to keep the data and presentation layer separate, I hope I succeeded in that.  In fact plasma framework provides a very good way of doing that in terms of data engines. I would also like to use the data engines, may be with this or other plasmoid I may develop.

    The svg images for weather conditions are taken from kde-look. The credit goes to the original artist, painkiller10. I have considered only a number of weather conditions, so If you see a question mark image as the weather condition, let me know which condition it is, so I can update the code to consider it.

    Please feel free to report any bugs or suggestions for improvement. I am sure there is a big room of improvement from code point of view as well as functionality. I am also open for changing the layout or changing the information displayed if someone comes with a better suggestion than the current one.

    Some more screen shots:

    Looks almost like conky with the seamless theme.

    Looks almost like conky with the seamless theme.

    wplasmoid_settings

    With settings dialog box

    Advertisements
     
    • Paolo 3:18 pm on September 2, 2009 Permalink | Reply

      Beautiful! BTW, could you internationalize your plasmoid? (in order to translate messages in other languages) Thanks.

      • hardikmehta 9:45 am on September 3, 2009 Permalink | Reply

        Thanks.

        I have plans to internationalize it, as soon as I get enough time to work on it.

    • arun kamath 5:04 am on September 13, 2009 Permalink | Reply

      I checked your source code at github. Instructions are for linux users. Can you please tell me how to run your program in windows?

    • Raffaele 2:06 pm on January 13, 2010 Permalink | Reply

      I like your plasmoid a lot, I’m enjoying it for months 😉
      Recently (maybe) google API changed a bit, because I got an error on wind string that halted my plasmoid 😦 Here is the patch
      http://pastebin.ca/1749545
      Where did you learn graphic widget programming for PyQt? I’d also like to, but I find the official doc inadequate (compared to Java’s for example… I’m a JStudent, too 🙂 )

      Cheers

      • hardikmehta 10:18 pm on January 13, 2010 Permalink | Reply

        Raffaele, thanks a lot. I have committed the patch to the repo and updated the package on kde-look. The incorrect format appears only for certain cities like Hong Kong. I tried to learn PyQT from the official documentation and also studying code of some existing plasmoids. It is true that compared to java, there is little help for learning PyQt or Python in general. I am a java developer just found python interesting. I am not sure about how pythonic my code is though 🙂

        Cheers.

    • DeltaKilo 4:10 pm on January 17, 2010 Permalink | Reply

      Good work! It is the first plasmoid showing weather in Russia!

      One little issue. SI unit for temperature isn’t °C but °K (Kelvin). It would be better to use imperial/metric switch.

    • DeltaKilo 4:11 pm on January 17, 2010 Permalink | Reply

      & kmph of course.. In SI should be mps

      • hardikmehta 12:05 pm on January 18, 2010 Permalink | Reply

        Thanks for using the plasmoid. Also thanks for pointing out the mistake. I corrected the names of the units and uploaded a new version with the new names. If you upgrade don’t for get to select the new units from the settings dialog box.

    • Raffaele 6:01 pm on April 8, 2010 Permalink | Reply

      Hi, I’m continuing enjoying your plasmoid 😀
      I found another little bug (actually a typo error) which sometimes prevents pyweather initialization. The problem occurs in weather.py http://pastebin.com/vX6HtkGb
      I don’t know if it’s fixed in most recent version, neither why sometimes it doesn’t fail. Happy coding!

      • hardikmehta 2:30 pm on April 20, 2010 Permalink | Reply

        Thanks for pointing out. I corrected and committed in the repo. Do you think we need a release for this ? I would rather wait and try to pack some feature with the bug fix.

    • Rick 5:16 pm on April 21, 2010 Permalink | Reply

      Hi, Thanks for the great plasmoid.
      Has everything my wife and I want except the ability to change font color. We noticed that the initial install will put in a dark or light font color (contrasting) according to the wallpaper used at that time. Would like to change the contrast when a different wallpaper is used. Is that possible?
      Thanks again.

      • hardikmehta 7:47 pm on April 21, 2010 Permalink | Reply

        Hi,

        Thanks for using the plasmoid.

        Actually, I just set the default font color for text which is selected by the current KDE theme. So, changing the font color with the current version of the plasmoid is only possible if you change the kde theme, which of course will change many other things. I liked your suggestion and would try to implement the font-color as config properties.

        cheers,
        Hardik

    • AmFreak 3:29 am on June 2, 2010 Permalink | Reply

      Hi,

      im planning to write a Plasmoid myself but i have a question.
      Is there a way to start the Plasmoid from Eclipse or do u have to run a script everytime u want to test it, like seen in the Getting Started Tutorial (http://techbase.kde.org/Development/Tutorials/Plasma/Python/GettingStarted) ?
      Thanks in advance.

      AmFreak

      • hardikmehta 6:43 am on June 2, 2010 Permalink | Reply

        I think pydev plugin provides ways to start any python script from eclipse, but I didn’t use that feature so cannot say how to do it. The recommended way to test is with plasmoidviewer, the application which comes as part of plasma environment.

    • AmFreak 2:34 am on June 5, 2010 Permalink | Reply

      But how can you debug a plasmoid if you only can test it with plasmoidviewer ?

    • luis 6:11 am on November 24, 2010 Permalink | Reply

      Thanks yu very much for the plasmoid, I found it really useful and very stylish.

      One question? is there a way to change the default Munich location? every time that I have to restart or crash, it automatically changes to the default

    • Giorgos Komninos (@giokom) 5:50 pm on March 18, 2012 Permalink | Reply

      I found a bug and it’s solution
      check my comment :
      http://opendesktop.org/content/show.php?content=110137&forumpage=3

      • hardikmehta 10:38 am on March 19, 2012 Permalink | Reply

        Hi Giorgos,

        Thanks for finding and fixing the issue. I will correct and release a new version as soon as I get some time.

        regards,
        Hardik

    • mike welder 1:12 am on September 3, 2012 Permalink | Reply

      as of recently I have not been able to start this “script initialization failed” is the message I get.it was working fine then I had a few updates and the above message started.It’s hard for me to tell which update did it as my computer stays on for weeks at a time with out logout or restart unless I have to so it’s hard for me to tell which update did it and when but it did start after a restart.I’m using fedora 17 kde.dam shame the one reason I’ve been with kde since fedora 15 is the great weather widget and a few others.Great work by the way.It’s not only your work there are a few others with the same message.

  • hardikmehta 10:37 am on June 29, 2009 Permalink | Reply
    Tags: eclipse, eclipse-plugin, galileo, glassfish,   

    Glassfish plugin on Eclipse 3.5 (Galileo) 

    Eclipse 3.5 also called Galileo is out. I tried to install the glassfish application server plugin with the standard method described here, but it failed with the following error message

    
    session context was:(profile=epp.package.jee, phase=org.eclipse.equinox.internal.provisional.p2.engine.phases.Collect, operand=, action=).
    No repository found containing: osgi.bundle,com.sun.enterprise.jst.server.sunappsrv,1.0.28
    No repository found containing: org.eclipse.update.feature,com.sun.enterprise.jst.server.sunappsrv.feature,1.0.28
    
    

    After searching a lot I found a way to install it using the update site http://ajax.dev.java.net/eclipse, like any other plugin. This worked well.

    May be the problem is temporary and after sometime the standard way will also start working.

     
    • rosdi 3:45 am on July 3, 2009 Permalink | Reply

      Thanks! It works like charm! Gracias!

      • hardikmehta 6:20 pm on July 3, 2009 Permalink | Reply

        Nice to know the information is useful.

    • Aaron 9:07 pm on July 3, 2009 Permalink | Reply

      Thanks, it worked 😀

    • salim 2:53 pm on July 7, 2009 Permalink | Reply

      it\’s really easy and it works well.
      thanks a lot.

    • ahsan 6:31 pm on July 7, 2009 Permalink | Reply

      it worked! thank you for your post.

    • Mladen 3:05 pm on July 11, 2009 Permalink | Reply

      Thanks a lot

    • Ramkumar 6:33 pm on July 25, 2009 Permalink | Reply

      Great! Thanks for the post.

    • merv 6:28 pm on July 26, 2009 Permalink | Reply

      Hey, thanks – this worked well 🙂

    • lukibill 2:06 pm on August 8, 2009 Permalink | Reply

      Thanks a lot, i spent a lot time for this problem

      But when i read your article , everything work well

    • druka 3:40 pm on August 17, 2009 Permalink | Reply

      God bless you!

    • hithesh 7:37 pm on August 18, 2009 Permalink | Reply

      thanks so much.

    • Henrique Otavio 11:01 pm on August 18, 2009 Permalink | Reply

      Tanks !!!

    • LewP 7:00 pm on September 15, 2009 Permalink | Reply

      I installed the lastest Glassfish, then Galileo 3.5. Then added the v3 Prelude Server into Eclipse. All kind of jars, etc. missing.

      When I downloaded the Glassfish/Eclipse bundle…no problems.

      Any ideas? Not to fond of bundles..

      • hardikmehta 7:15 pm on September 15, 2009 Permalink | Reply

        It would help to see the error message or at least the jars which are missing,

    • Joe Vacha 3:57 am on December 2, 2009 Permalink | Reply

      thanks a lot – this worked well 🙂

    • Seva 2:54 pm on December 7, 2009 Permalink | Reply

      Thanks, it worked out.

    • Konstantin 6:04 pm on December 11, 2009 Permalink | Reply

      It doesn’t work!!!

      ERROR:
      Cannot complete the install because one or more required items could not be found.
      Software currently installed: GlassFish Java EE 5, Java EE 6 1.0.44 (com.sun.enterprise.jst.server.sunappsrv.feature.feature.group 1.0.44)
      Missing requirement: Sun Application Servers and GlassFish Servers support 1.0.44 (com.sun.enterprise.jst.server.sunappsrv 1.0.44) requires ‘bundle org.eclipse.jst.jee.web 1.0.100’ but it could not be found
      Cannot satisfy dependency:
      From: GlassFish Java EE 5, Java EE 6 1.0.44 (com.sun.enterprise.jst.server.sunappsrv.feature.feature.group 1.0.44)
      To: com.sun.enterprise.jst.server.sunappsrv [1.0.44]

      • Konstantin 1:08 pm on December 14, 2009 Permalink | Reply

        Additionaly: I’ve used a minimal eclipse galileo 3.5.1 installation plus the j2ee plugin. Which plugin do I also have to install?

    • SAMK 8:31 am on May 27, 2010 Permalink | Reply

      Thanks a lot it worked!

    • uni 8:48 am on December 6, 2011 Permalink | Reply

      terima kasih banyak atas bantuannya. thank’s a lot ^_^

  • hardikmehta 2:50 pm on April 4, 2009 Permalink | Reply
    Tags: eclipse, , , , Programming   

    Eclipse: Timeout configuration of server (jboss) 

    I configured JBOSS 5 Application Server with  Eclipse 3.4. The configuration was successful. When I tried to start it though, the start up failed with the error  message that it had timed out, the timeout was set to 50 seconds. It is amazing that JBOSS takes more than a minute to start up.

    After some searching, I came to know that in Eclipse 3.4 the server timeouts can be configured per individual servers. Opening the server with double clicking in the server view, will list the timeout option and can be set in seconds. Here the screen-shot.

    eclipse_server_timeout1

     
    • Farkas Gabor 11:21 am on July 15, 2009 Permalink | Reply

      omg, thanx a lot for the screenshot, i spent months searching for this setting. The thing I never thought of was that I have to *doubleclick* the server in the servers view. I was searching for this window everywhere else …
      btw, jboss starting up for more than a minute is not that odd, as compared to WAS or Weblogic. Many times hibernate schema creation or update also adds up to this time.
      In some weird cases I even needed to debug my application startup, which I could not do during jboss startup due to this timeout …
      cheers

      • hardikmehta 12:28 pm on July 15, 2009 Permalink | Reply

        Yes, the page is so obscure, it is hard to think about double click. I wrote this post for future reference. Corrected the post with the double click info.

        Thanks for the explanation about jboss startup.

    • Dragon 12:56 pm on September 3, 2009 Permalink | Reply

      That is increadible !!! Double Click !!! I spent 4 hours only to find this…

      • Arif 1:08 pm on March 4, 2010 Permalink | Reply

        I had to spend a day to find out that u just have to double click the server. This is actually very unintuitive cause these kind of property settings should be available via popup when u right click the server.

        I must say that I have found Netbeans much user friendly and intuitive as compared to Eclipse. Every other organization (like Redhat, IBM etc) are trying to change Eclipse in its own way RedHat has its own version of eclipse called “Jboss Developer Studio” and obviously RedHat wants to sell it (for 99$) thats why Jboss Tools dont work properly in eclipse.

        Eclipse sucks!!! Netbeans Rules!!!

    • Zohaib 11:27 am on November 23, 2012 Permalink | Reply

      Thanx ……..

c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel
%d bloggers like this: