Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9001585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:27:22+00:00 2026-06-16T00:27:22+00:00

Hello all I’ve been learning python and pygtk I’ve recently run into an issue

  • 0

Hello all I’ve been learning python and pygtk I’ve recently run into an issue with a small program i was trying to make.

When you click the tray icon the first time my window appears as normal but after closing the window which I tried to set to be like a “minimize to tray” type thing it won’t open again only display a blank window instead of the one it shows originally.


    import os
    import gtk
    import gobject
    import datepicker
    from dateutil import relativedelta
    import datetime
    import numberentry
    class ShutdownTimer:
        tray_tooltip = ''
        timer_visible = False
        timerui = gtk.Window()
        def set_tooltip(self, string):
            self.tray_tooltip = str(string)
        def set_visible(self, v, visible):
        self.timer_visible = visible
        if self.timer_visible is True:
            self.timerui.show_all()
        else:
            self.timerui.hide_all()
        def set_up(self):
            self.timerui.set_title("Shutdown Timer")
            self.timerui.connect("destroy", self.set_visible, False)
            self.row_one = gtk.HBox()
            self.combo = gtk.combo_box_new_text()
            self.combo.append_text("Shutdown")
            self.combo.append_text("Hibernate")
            self.combo.append_text("Suspend/Sleep")
            self.combo.append_text("Restart")
            self.combo.append_text("Cancel")
            self.combo.set_active(0)
            self.row_one.pack_start(self.combo, False, False)

            hlbl = gtk.Label()
            mlbl = gtk.Label()
            hlbl.set_text("H:")
            mlbl.set_text("M:")

            self.hentry = numberentry.NumberEntry()
            self.mentry = numberentry.NumberEntry()
            submit = gtk.Button("Submit")
            submit.connect("clicked", self.submit_action)

            self.row_one.pack_start(hlbl, False, False)
            self.row_one.pack_start(self.hentry, False, False)
            self.row_one.pack_start(mlbl, False, False)
            self.row_one.pack_start(self.mentry, False, False)
            self.row_one.pack_start(submit, False, False)

            self.row_one.show_all()

            self.timerui.add(self.row_one)


        def submit_action(self, action):
            task = self.combo.get_active_text()
            hours = int(self.hentry.get_text())
            minus = int(self.mentry.get_text())
            hourm = hours * 60
            tmins = minus + hourm
            tseconds = tmins * 60
            print tseconds

            date = datetime.datetime.now()
            print date

            future = datetime.timedelta(seconds=tseconds)
            total = date+future
            print total

            print "%s scheduled for %s" % (task, total)
            string = task + " scheduled for " + str(total)
            md = gtk.MessageDialog(self.timerui, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, string)
            md.run()
            md.destroy()
        #print '%s - %s / %i:%i %s' % (action, date, hours, minutes, timePart)
        #date_split = date.split("/")
        #today = datetime.date.today(date_split[2],date_split[0], date_split[1])
        #rd = relativedelta(today, datetime.date())
        #print "Seconds to go: %(seconds)d" % rd.__dict__
        def on_right_click(self, shutdown, status, action):
            menu = gtk.Menu()

            menu_item = gtk.MenuItem("Quit")
            menu_item.connect("activate", lambda w: gtk.main_quit())
            menu.append(menu_item)
            menu_item.show()
            menu_item = gtk.MenuItem("Show Window")
            menu_item.connect("activate", self.set_visible, True)
            menu.append(menu_item)
            menu_item.show()
            menu.popup(None, None, None, action, action)
        def __init__(self):
            self.status = gtk.StatusIcon()
            home = os.getenv('HOME')
            icon_path = home + '/.config/shutdowntimer/icons/32x32/tray_icon.png'
            settings_path = home + '/.config/shutdowntimer/settings/'
            self.status.set_from_file(icon_path)
            self.status.set_visible(True)
            self.status.connect("popup_menu", self.on_right_click)
            self.status.connect("activate", self.set_visible, True)
            self.set_up()

    def main():
        gtk.main()
        return 0

    if __name__ == "__main__":
    ShutdownTimer()
    main()

I’m sure i’ve got some issues going on in my code as far as formatting, commenting, and probably naming conventions but any help shedding light on my issue would be appreciated.. Thank you :)!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:27:23+00:00Added an answer on June 16, 2026 at 12:27 am

    Sorry for wasting anyones time I managed to solve my issue by calling self.set_up() in this specific spot

     def set_visible(self, v, visible):
        self.timer_visible = visible
        if self.timer_visible is True:
            self.set_up()
            self.timerui.show_all()
        else:
            self.timerui.hide_all()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello all im trying to make this slide effect http://tinyurl.com/628z32d but im new to
Hello all im trying to add a class when i focus on a small
hello all I have a small dialog which I created dynamically, which has a
Hello all I am newbie to webrtc just started to run my first application
Hello all I have this problem that I can't seem to fix. I've been
Hello all I want to make a filter for tomcat to deflate all responces
Hello all would anyone know how flickr manage to make this type of effect
Hello all I am getting an error Run-time error '9': Subscript out of range
Hello All , I am trying to use preg_match to identify if a single
Hello all I'm trying to change the skin (shape) of the button and textArea

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.