Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9fb42e49529e
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 82330b3c2a7d
Choose a head ref
  • 2 commits
  • 6 files changed
  • 1 contributor

Commits on Jan 23, 2015

  1. Verified

    This commit was signed with the committer’s verified signature.
    makenowjust Hiroya Fujinami
    Copy the full SHA
    f983fdc View commit details
  2. gui: save layout

    sbourdeauducq committed Jan 23, 2015
    Copy the full SHA
    82330b3 View commit details
Showing with 78 additions and 15 deletions.
  1. +15 −3 artiq/frontend/artiq_gui.py
  2. +5 −3 artiq/gui/parameters.py
  3. +2 −2 artiq/gui/rt_results.py
  4. +5 −3 artiq/gui/scheduler.py
  5. +42 −2 artiq/gui/tools.py
  6. +9 −2 artiq/protocols/file_db.py
18 changes: 15 additions & 3 deletions artiq/frontend/artiq_gui.py
Original file line number Diff line number Diff line change
@@ -7,7 +7,9 @@
import gbulb
from gi.repository import Gtk

from artiq.protocols.file_db import FlatFileDB
from artiq.protocols.pc_rpc import AsyncioClient
from artiq.gui.tools import LayoutManager
from artiq.gui.scheduler import SchedulerWindow
from artiq.gui.parameters import ParametersWindow
from artiq.gui.rt_results import RTResults
@@ -24,12 +26,18 @@ def get_argparser():
parser.add_argument(
"--port-control", default=3251, type=int,
help="TCP port to connect to for control")
parser.add_argument(
"--db-file", default="artiq_gui.pyon",
help="database file for local GUI settings")
return parser


def main():
args = get_argparser().parse_args()

db = FlatFileDB(args.db_file, default_data=dict())
lmgr = LayoutManager(db)

asyncio.set_event_loop_policy(gbulb.GtkEventLoopPolicy())
loop = asyncio.get_event_loop()
atexit.register(lambda: loop.close())
@@ -40,15 +48,18 @@ def main():
args.server, args.port_control, "master_schedule"))
atexit.register(lambda: schedule_ctl.close_rpc())

scheduler_win = SchedulerWindow(schedule_ctl)
scheduler_win = lmgr.create_window(SchedulerWindow,
"scheduler",
schedule_ctl)
scheduler_win.connect("delete-event", Gtk.main_quit)
scheduler_win.show_all()
loop.run_until_complete(scheduler_win.sub_connect(
args.server, args.port_notify))
atexit.register(
lambda: loop.run_until_complete(scheduler_win.sub_close()))

parameters_win = ParametersWindow()
parameters_win = lmgr.create_window(ParametersWindow,
"parameters")
parameters_win.connect("delete-event", Gtk.main_quit)
parameters_win.show_all()
loop.run_until_complete(parameters_win.sub_connect(
@@ -62,8 +73,9 @@ def main():
atexit.register(
lambda: loop.run_until_complete(rtr.sub_close()))


loop.run_forever()

lmgr.save()

if __name__ == "__main__":
main()
8 changes: 5 additions & 3 deletions artiq/gui/parameters.py
Original file line number Diff line number Diff line change
@@ -28,9 +28,11 @@ def convert(self, x):


class ParametersWindow(Window):
def __init__(self):
Window.__init__(self, title="Parameters")
self.set_default_size(500, 500)
def __init__(self, **kwargs):
Window.__init__(self,
title="Parameters",
default_size=(500, 500),
**kwargs)

notebook = Gtk.Notebook()
self.add(notebook)
4 changes: 2 additions & 2 deletions artiq/gui/rt_results.py
Original file line number Diff line number Diff line change
@@ -13,8 +13,8 @@ def __init__(self, set_names):
self.set_names = set_names
self.data = None

Window.__init__(self, title="/".join(set_names))
self.set_default_size(700, 500)
Window.__init__(self, title="/".join(set_names),
default_size=(700, 500))

self.darea = Gtk.DrawingArea()
self.darea.set_size_request(100, 100)
8 changes: 5 additions & 3 deletions artiq/gui/scheduler.py
Original file line number Diff line number Diff line change
@@ -34,11 +34,13 @@ def convert(self, trid, x):


class SchedulerWindow(Window):
def __init__(self, schedule_ctl):
def __init__(self, schedule_ctl, **kwargs):
self.schedule_ctl = schedule_ctl

Window.__init__(self, title="Scheduler")
self.set_default_size(720, 570)
Window.__init__(self,
title="Scheduler",
default_size=(720, 570),
**kwargs)

topvbox = Gtk.VBox(spacing=6)
self.add(topvbox)
44 changes: 42 additions & 2 deletions artiq/gui/tools.py
Original file line number Diff line number Diff line change
@@ -7,12 +7,52 @@


class Window(Gtk.Window):
def __init__(self, *args, **kwargs):
Gtk.Window.__init__(self, *args, **kwargs)
def __init__(self, title, default_size, layout_dict=dict()):
Gtk.Window.__init__(self, title=title)

self.set_wmclass("ARTIQ", "ARTIQ")
self.set_icon_from_file(os.path.join(data_dir, "icon.png"))
self.set_border_width(6)

try:
size = layout_dict["size"]
except KeyError:
size = default_size
self.set_default_size(size[0], size[1])
try:
position = layout_dict["position"]
except KeyError:
pass
else:
self.move(position[0], position[1])

def get_layout_dict(self):
return {
"size": self.get_size(),
"position": self.get_position()
}


class LayoutManager:
def __init__(self, db):
self.db = db
self.windows = dict()

def create_window(self, cls, name, *args, **kwargs):
try:
win_layouts = self.db.request("win_layouts")
layout_dict = win_layouts[name]
except KeyError:
layout_dict = dict()
win = cls(*args, layout_dict=layout_dict, **kwargs)
self.windows[name] = win
return win

def save(self):
win_layouts = {name: window.get_layout_dict()
for name, window in self.windows.items()}
self.db.set("win_layouts", win_layouts)


class ListSyncer:
def __init__(self, store, init):
11 changes: 9 additions & 2 deletions artiq/protocols/file_db.py
Original file line number Diff line number Diff line change
@@ -5,9 +5,16 @@


class FlatFileDB:
def __init__(self, filename):
def __init__(self, filename, default_data=None):
self.filename = filename
self.data = Notifier(pyon.load_file(self.filename))
try:
data = pyon.load_file(self.filename)
except FileNotFoundError:
if default_data is None:
raise
else:
data = default_data
self.data = Notifier(data)
self.hooks = []

def save(self):