Skip to content

Instantly share code, notes, and snippets.

@Gwith
Created August 25, 2017 17:22
Show Gist options
  • Save Gwith/0f3d92f88cfba12383334fd3cd70e17a to your computer and use it in GitHub Desktop.
Save Gwith/0f3d92f88cfba12383334fd3cd70e17a to your computer and use it in GitHub Desktop.
from PyQt5.QtWidgets import QHeaderView
from ui_orderconversion import Ui_OrderConversion
class OrderConversion(Ui_OrderConversion):
def __init__(self):
super().__init__()
self.setupUi(self)
self.column_width()
self.orders_table.cellChanged.connect(self.add_row)
self.show()
def add_row(self):
'''Add row if order number added to first cell in each column'''
c_row = self.orders_table.currentRow()
c_col = self.orders_table.currentColumn()
value = self.orders_table.item(c_row, c_col)
value = value.text()
rc = self.orders_table.rowCount()
if c_col == 0 and len(value) == 2:
self.orders_table.insertRow(rc)
def column_width(self):
'''Adds headers to each column and sets wdith'''
col_headers = ['OrderNum', 'Converted/Printed', 'FaxEmail', 'RequestDate', 'HOT']
self.orders_table.setHorizontalHeaderLabels(col_headers)
self.orders_table.horizontalHeader().setStretchLastSection(True)
self.orders_table.setColumnWidth(1, 120)
self.orders_table.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
def column_checkbox(self):
'''Add checkbox to column 1 and 4'''
'''Currently just print statements, will change soon'''
#print(self.orders_table.columnCount())
#print(self.orders_table.rowCount())
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'ui_tammy.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtWidgets
class Ui_OrderConversion(QtWidgets.QMainWindow):
def setupUi(self, OrderConversion):
OrderConversion.setObjectName("OrderConversion")
OrderConversion.resize(1701, 814)
self.centralwidget = QtWidgets.QWidget(OrderConversion)
self.centralwidget.setObjectName("centralwidget")
self.web_view = QtWebKitWidgets.QWebView(self.centralwidget)
self.web_view.setGeometry(QtCore.QRect(600, 19, 1091, 741))
self.web_view.setMinimumSize(QtCore.QSize(1091, 741))
self.web_view.setMaximumSize(QtCore.QSize(1091, 741))
self.web_view.setUrl(QtCore.QUrl(http://www.google.com"))
self.web_view.setObjectName("web_view")
self.order_numbers = QtWidgets.QLabel(self.centralwidget)
self.order_numbers.setGeometry(QtCore.QRect(30, 20, 91, 16))
self.order_numbers.setObjectName("order_numbers")
self.order_in_list_count = QtWidgets.QLabel(self.centralwidget)
self.order_in_list_count.setGeometry(QtCore.QRect(310, 20, 91, 21))
self.order_in_list_count.setObjectName("order_in_list_count")
self.orders_table = QtWidgets.QTableWidget(self.centralwidget)
self.orders_table.setGeometry(QtCore.QRect(30, 40, 551, 421))
self.orders_table.setObjectName("orders_table")
self.orders_table.setColumnCount(5)
self.orders_table.setRowCount(1)
self.convert_order_si = QtWidgets.QPushButton(self.centralwidget)
self.convert_order_si.setGeometry(QtCore.QRect(30, 470, 75, 51))
self.convert_order_si.setObjectName("convert_order_si")
self.print_all_orders = QtWidgets.QPushButton(self.centralwidget)
self.print_all_orders.setGeometry(QtCore.QRect(110, 470, 75, 51))
self.print_all_orders.setObjectName("print_all_orders")
self.fax_all_orders = QtWidgets.QPushButton(self.centralwidget)
self.fax_all_orders.setGeometry(QtCore.QRect(190, 470, 75, 51))
self.fax_all_orders.setObjectName("fax_all_orders")
self.email_all_orders = QtWidgets.QPushButton(self.centralwidget)
self.email_all_orders.setGeometry(QtCore.QRect(270, 470, 75, 51))
self.email_all_orders.setObjectName("email_all_orders")
self.mixed_send_fax_email = QtWidgets.QPushButton(self.centralwidget)
self.mixed_send_fax_email.setGeometry(QtCore.QRect(350, 470, 75, 51))
self.mixed_send_fax_email.setObjectName("mixed_send_fax_email")
self.clear = QtWidgets.QPushButton(self.centralwidget)
self.clear.setGeometry(QtCore.QRect(430, 470, 151, 21))
self.clear.setObjectName("clear")
self.uncheck_all = QtWidgets.QPushButton(self.centralwidget)
self.uncheck_all.setGeometry(QtCore.QRect(430, 500, 151, 21))
self.uncheck_all.setObjectName("uncheck_all")
OrderConversion.setCentralWidget(self.centralwidget)
self.retranslateUi(OrderConversion)
QtCore.QMetaObject.connectSlotsByName(OrderConversion)
def retranslateUi(self, OrderConversion):
_translate = QtCore.QCoreApplication.translate
OrderConversion.setWindowTitle(_translate("OrderConversion", "MainWindow"))
self.order_numbers.setText(_translate("OrderConversion", "Order Numbers"))
self.order_in_list_count.setText(_translate("OrderConversion", "orders in list"))
self.convert_order_si.setText(_translate("OrderConversion", "Convert \n"
"Orders to SI"))
self.print_all_orders.setText(_translate("OrderConversion", "Print All\n"
" Orders"))
self.fax_all_orders.setText(_translate("OrderConversion", "FAX All \n"
"Orders"))
self.email_all_orders.setText(_translate("OrderConversion", "Email All \n"
"Orders"))
self.mixed_send_fax_email.setText(_translate("OrderConversion", "Mixed Send \n"
"Fax/Email"))
self.clear.setText(_translate("OrderConversion", "Clear"))
self.uncheck_all.setText(_translate("OrderConversion", "Uncheck All"))
from PyQt5 import QtWebKitWidgets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment