Skip to content

Commit

Permalink
fix: Fixed PPT export
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubenknex committed Sep 1, 2016
1 parent 35bc440 commit 2654790
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
1 change: 0 additions & 1 deletion qtplot/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ def on_mouse_move(self, event):

# If we are within the plot window
if 0 <= sx < sw and 0 <= sy < sh:
print(event.pos, type(event.pos))
x, y = self.screen_to_data_coords((event.pos[0], event.pos[1]))

if not np.isnan(x) and not np.isnan(y):
Expand Down
4 changes: 3 additions & 1 deletion qtplot/colormap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@


class Colormap:
""" Represents a colormap to be used for plotting. """
def __init__(self, filename):
""" Construct from a spyview colormap. """
dir = os.path.dirname(os.path.realpath(__file__))
path = os.path.join(dir, filename)

Expand Down Expand Up @@ -38,6 +40,6 @@ def get_colors(self):
def get_mpl_colormap(self):
"""
Create a matplotlib colormap object that can be used in the cmap
argument of some plotting functions.
argument of some matplotlib plotting functions.
"""
return mpl.colors.ListedColormap(self.get_colors().astype(float) / 255.0)
8 changes: 2 additions & 6 deletions qtplot/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,11 @@ def on_to_ppt(self):

app = win32com.client.Dispatch('PowerPoint.Application')

pres = app.ActivePresentation

# Paste the plot on the active slide
slide = app.ActiveWindow.View.Slide
slide.Shapes.Paste()

shape = slide.Shapes[len(slide.Shapes) - 1]
shape.ActionSettings[0].Action = 9
shape.ActionSettings[0].Run = 'qtplot-console "%s"' % self.main.filename
shape = slide.Shapes.Paste()
shape.ActionSettings[0].Hyperlink.Address = self.main.abs_filename

def on_export(self):
path = os.path.dirname(os.path.realpath(__file__))
Expand Down
18 changes: 5 additions & 13 deletions qtplot/qtplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,7 @@


class QTPlot(QtGui.QMainWindow):
"""
The main window of the qtplot application.
Program flow:
Open application
- Create UI
Load a file (either via UI or startup. startup should be after create UI)
Open current state
"""
""" The main window of the qtplot application. """
def __init__(self, filename=None):
super(QTPlot, self).__init__(None)

Expand All @@ -77,6 +65,7 @@ def __init__(self, filename=None):

# In case of a .dat file
self.filename = None
self.abs_filename = None
self.dat_file = None

# In case of a qcodes DataSet(Lite)
Expand Down Expand Up @@ -281,6 +270,7 @@ def init_ui(self):
cmap_files.append(relfile)

self.cb_cmaps.addItems(cmap_files)
self.cb_cmaps.setMaxVisibleItems(25)

hbox_gamma1.addWidget(self.cb_cmaps)

Expand Down Expand Up @@ -448,6 +438,7 @@ def load_dat_file(self, filename):
if filename != self.filename:
path, self.name = os.path.split(filename)
self.filename = filename
self.abs_filename = os.path.abspath(filename)

self.open_state(self.profile_ini_file)

Expand Down Expand Up @@ -609,6 +600,7 @@ def on_data_change(self):
if self.data is None:
return
elif self.data_set is not None:
# Create a Data2D object from qcodes DataSet
x = self.data_set.arrays[x_name].array
y = self.data_set.arrays[y_name].array
z = self.data_set.arrays[data_name].array
Expand Down

0 comments on commit 2654790

Please sign in to comment.