Quick and easy: trayicon with python?

For Windows & Gnome Here ya go! wxPython is the bomb. Adapted from the source of my Feed Notifier application. import wx TRAY_TOOLTIP = ‘System Tray Demo’ TRAY_ICON = ‘icon.png’ def create_menu_item(menu, label, func): item = wx.MenuItem(menu, -1, label) menu.Bind(wx.EVT_MENU, func, id=item.GetId()) menu.AppendItem(item) return item class TaskBarIcon(wx.TaskBarIcon): def __init__(self): super(TaskBarIcon, self).__init__() self.set_icon(TRAY_ICON) self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.on_left_down) def … Read more

Dark theme for Qt widgets?

No, but you may use my fairly comprehensive stylesheets that should look excellent on most platforms (it’s inspired by KDE’s Breeze Theme, which is a dark theme that is quite elegant). This was (hard) forked from the excellent QDarkStylesheet, which I felt had theme issues in numerous areas, so I modified it extensively for my … Read more

pyqt: how to remove a widget?

If your widget have no child widgets that depend on it i think you can use: layout.removeWidget(self.widget_name) self.widget_name.deleteLater() self.widget_name = None in my tests when it is a widget that have childs you have to: import sip layout.removeWidget(self.widget_name) sip.delete(self.widget_name) self.widget_name = None if you don’t have a variable name for the widget at class or … Read more

How do I plot only a table in Matplotlib?

This is another option to write a pandas dataframe directly into a matplotlib table: import numpy as np import pandas as pd import matplotlib.pyplot as plt fig, ax = plt.subplots() # hide axes fig.patch.set_visible(False) ax.axis(‘off’) ax.axis(‘tight’) df = pd.DataFrame(np.random.randn(10, 4), columns=list(‘ABCD’)) ax.table(cellText=df.values, colLabels=df.columns, loc=”center”) fig.tight_layout() plt.show()

Detecting enter on a QLineEdit or QPushButton

For the QLineEdit connect to the returnPressed signal. Alternatively, if you use the setAutoDefault method on your QPushButtons you emit the clicked signal when Enter is pressed on a focused QPushButton: #!/usr/bin/env python #-*- coding:utf-8 -*- import sip sip.setapi(‘QString’, 2) sip.setapi(‘QVariant’, 2) from PyQt4 import QtGui, QtCore class MyWindow(QtGui.QWidget): def __init__(self, parent=None): super(MyWindow, self).__init__(parent) self.pushButtonOK … Read more

Clear all widgets in a layout in pyqt

After a lot of research (and this one took quite time, so I add it here for future reference), this is the way I found to really clear and delete the widgets in a layout: for i in reversed(range(layout.count())): layout.itemAt(i).widget().setParent(None) What the documentation says about the QWidget is that: The new widget is deleted when … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)