Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import gtk
- import re
- import os
- import time
- active_button = 0
- servers = [["Server 1","/home/myname/Desktop/server1","server.jar"],
- ["Serveur 2","/home/myname/Desktop/server2","server.jar"]]
- def button_selection(button, num):
- global active_button
- state=button.state
- if state >= 1:
- active_button = int(num)
- def validation(widget):
- path = servers[active_button][1]
- server = servers[active_button][2]
- command = """gnome-terminal --working-directory="%s" -e 'java -jar %s'""" % (path, server)
- print(command)
- os.system(command)
- def save(widget):
- path = servers[active_button][1]
- server = servers[active_button][2]
- print "cp -a '%s' /home/myname/Documents/backups_minecraft_servers/%s" % (path+"/world", time.strftime("%d_%m_%Y-%T"))
- os.system("cp -a '%s' /home/myname/Documents/backups_minecraft_servers/%s" % (path+"/world", time.strftime("%d_%m_%Y-%T")))
- print("Backup finished")
- def main():
- window = gtk.Window()
- vbox = gtk.VBox()
- hbox = gtk.HBox()
- validate = gtk.Button("Validate")
- validate.connect("clicked", validation)
- backup = gtk.Button("Backup")
- backup.connect("clicked", save)
- hbox.pack_start(validate)
- hbox.pack_start(vbox)
- hbox.pack_start(backup)
- buttons = [gtk.RadioButton(None, servers[0][0])]
- vbox.pack_start(buttons[0])
- for server in servers[1:]:
- buttons.append(gtk.RadioButton(buttons[0], server[0]))
- vbox.pack_start(buttons[-1])
- for i in range(len(buttons)):
- buttons[i].connect("toggled", button_selection, i)
- window.add(hbox)
- window.show_all()
- gtk.main()
- if __name__=="__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement