Monday, April 29, 2024
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 993  / 3 Years ago, fri, october 8, 2021, 2:10:25

I'm very new to linux and I don't know very much. I was creating my own application with Quickly, and I wanted to have a button which launches the Hardware Information application "Hardinfo". I'm very new and I literally don't know anything, any help would be very much appreciated. Thanks in advance!



Update: I'm not looking for a keyboard shortcut, by button I meant a gtk-button inside glade. How to I set it so that when clicked it would take me to the application "hardinfo". If this isn't possible, then how can I set the button to emulate a keyboard shortcut once clicked, inside glade, Thankssssss!



Update 2: What I'm looking for is a step by step process of how to do this from someone who knows glade and quickly completely, because I have no idea how the codes work and where I'm supposed to put them :/


More From » application-development

 Answers
2

OK, how about a clear and concise (working) example:




  1. quickly create ubuntu-application test

  2. cd test

  3. quickly design

  4. Add a button somewhere with Glade (by default it is called "button1")

  5. Save and close Glade

  6. quickly edit and go to TestWindow.py

  7. Add the following at the top of the file:



    from multiprocessing import Process
    import subprocess

  8. Add the following to the end of the file and make sure it is indented properly (pro tip: select the block of text in Gedit and hit tab to indent the whole block):



    def on_button1_clicked(self, widget, data=None):
    p = Process(target=self.launch_hardinfo)
    p.start()

    def launch_hardinfo(self):
    subprocess.call(["hardinfo"])


    These two functions work together. Process.start() calls TestWindow.launch_hardinfo (that's the target= parameter to the Process constructor) in a new thread so that subprocess.call() doesn't block the application.


  9. Save TestWindow.py


  10. quickly run and and click the button.



I had a little issue because I was trying to assign signals in Glade, but you don't even need to do that. The Quickly library actually allows you to do stuff like on_button1_click() which means "when the control called button1 is clicked." Simple as that! Hopefully this should get you started.



See also: Creating Ubuntu Application with Quickly


[#25507] Friday, October 8, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ntlesslving

Total Points: 123
Total Questions: 109
Total Answers: 113

Location: South Korea
Member since Fri, Sep 11, 2020
4 Years ago
;