What about Microsoft Visual C++ Redistributable packages on Windows

I’ve found that, at times, the Visual C++ problem can be pretty frustrating. When you install software that uses one of these packages it is often installed as part of the installation but not always. I wondered why you need one of these packages and why do you have to have several installed covering various years, versions and both 32 bit (x86) and 64 bit. At this count, I have 13 versions installed covering years 2008 to 2017.

Here is a good article explaining why they are needed:

https://www.howtogeek.com/256245/why-are-there-so-many-microsoft-visual-c-redistributables-installed-on-my-pc/

Condor reinstallation and UB DirectPlay8 Error

I re-installed Condor yesterday using my original installation directory on D:\Condor. Condor is pretty slow to open in a task from large HD sceneries like Arc Alpin (AA). I didn’t want to install on my C:\ drive (which is the Samsung NVMe SSD drive) because of potential space problems. Today, I tried to join a task from one of the public servers. When I clicked on the join button I received this error:

I searched the web for a solution and the simplest one was the one that worked. That was to simply open “Turn Windows Features On or Off” from the control panel; scroll down to the Legacy Components setting and click DirectPlay:

Before trying this fix I uninstalled Condor from the D:\ drive and installed it on C:\Condor.

The next problem was that, since I had moved the Condor directory from c:\ to d:\, the goodies downloads stopped working. I tried several things, including using MS Edge instead of Chrome, none of which worked. Finally I decided to search the registry for an instance of CTDB. I found one that showed the goodies location at d:\condor\goodies. I changed the ‘d’ to a ‘c’ and that fixed the problem!

And, by the way, Condor and tasks don’t seem to load much, if any faster, from the SSD!

Preparing to build a new computer

I am doing much research into building a new computer. I’ve been working with pcpartpicker, Tom’s Hardware, and other sites. pcpartpicker is really nice and a great help. Thank you pcpartpicker!

One of my conundrum has been deciding among so many choices for motherboards. Specs I see for Asus motherboards costing $385 seem pretty much the same as those costing $175, so what, exactly, is the difference?

Here is an article I just found that I hope will answer some of my questions.

And here is a breakdown of all Corsair coolers.

Strix Z270E Gaming has wifi and bluetooth, excellent audio with noise suppression.

Discontinuing my Blue Host hosting service — Transferring all content to my wordpress.com site.

My subscription with Blue Host hosting service expires today. I’ve been downloading the site via FTP and downloading the backups I’ve been paying for for several years. I’m also exporting all content for each of my sites: tortui.com, coffee.tortui.com, journal.tortui.com, csic.tortui.com and travel.tortui.com. I finally feel about doing this. I really do very little on any of the sites only making an occasional blog. I was hesitant to leave my hosting service because of the much reduced control that I have over this wordpress.com site. On the other hand, I’ve been getting a lot of malware on those sites and am not committed to keeping everything in safe and good working order. So one of the big advantages of using this site instead is that I don’t need to worry about security. Another thing is that this site is much faster than a shared hosting service.

Converting PyQt4 code from Rapid GUI Programming with Python and Qt to PyQt5

Notes on converting the PyQt4 code from Mark Summerfield’s book to PyQt5
I’ve been working at this a while and have quite a few notes and suggestions.
  • In the code examples from the book, all Qstrings are converted to Unicode. With PyQt5 this is no longer necessary. Just use python 3 strings in place of Qstrings and the Qstring will be converted automatically since python 3 strings are already unicode. I’m not sure if this works in python 2 though.
  • All of the SIGNAL and SLOT code from the book uses the old style of defining signals and slots and their connections. The new way is MUCH simpler and allows you to throw away a lot of the detail of the old style. Here is an example. The first line is the old style syntax. The second line is the new style syntax introduced in PyQt 4.5:
        old style: self.connect(self.table, SIGNAL(“itemDoubleClicked(QTableWidgetItem*)”),   self.editEdit)
        new style: self.table.itemDoubleClicked.connect(self.editEdit)
  • Connections are made using QObject.connect(), broken using QOBject.disconnect() and emitted using QObject.emit()
To create a custom signal it’s a little trickier what you need to do is to declare the signal as a class attribute. Class attributes must appear at the very beginning of your class definition, before any methods. Here is an example from chapter 4 of PyQt book:
import sys
from PyQt5.QtCore import *
# from PyQt4.QtGui import *
from PyQt5.QtWidgets import *
class ZeroSpinBox(QSpinBox):
    atzero = pyqtSignal(int)
    zeros = 0
    def __init__(self):
        super().__init__()
        self.valueChanged.connect(self.checkzero)
    def checkzero(self):
        if self.value() == 0:
            self.zeros += 1
            self.atzero.emit(self.zeros)
                      # in the original PyQt4 program the atzero signal was created and emitted in one line of code:
                      #  self.emit(SIGNAL(“atzero”), self.zeros)
class Form3(QDialog):
    def __init__(self):
        super().__init__()
        dial = QDial()
        dial.setNotchesVisible(True)
        self.zerospinbox = ZeroSpinBox()
   …
     skip some code
   …
        self.zerospinbox.atzero.connect(self.announce)
        self.setWindowTitle(“Signals and Slots”)
    def announce(self, zeros):
        print(“ZeroSpinBox has been at zero {} times”.format(zeros))
        # print(dir(zeros))
  • Since the ZeroSpinBox widget doesn’t have an atzero signal so a subclass of QSpinBox must be written to include the signal, which has been done in the ZeroSpinBox class with the declaration of the atzero signal. It can then be emitted in the checkzero() method where if the value of an instance of ZeroSpinBox (zerospinbox here) is 0, the atzero signal is triggered. A connection is setup in the __init__ that calls self.announce when the signal is emitted. The signal also passes the value of self.zeros which has the number of times that the spinbox reached 0.
  • In PyQt4, QFileDialog.getOpenFileName() and QFileDialog.getSaveFileName() return a str with the filename but in PyQt5 they return a tuple which can contain the file name as the first element of the tuple and the extension filter as the second element or an empty element. This can cause problems if you don’t modify the behavior of the code. One solution to to refer to the file name as filename[0] but this can be tricky. The easiest solution is change the assignment statement from
    • filename = QFileDialog.getOpenFileName() to
    • filename, _ = QFileDialog.getOpenFileName()
  • This will throw out the second element of the tuple and filename will just get a str containing the file name. The rest of the code should work the same as it did in PyQt4.
def fileOpen(self):
    filename, _ = QFileDialog.getOpenFileName(self,
            "SDI Text Editor -- Open File")
    if filename:
        if (not self.editor.document().isModified() and
            self.filename.startswith("Unnamed")):
            self.filename = filename
            self.loadFile()
        else:
            MainWindow(filename).show()

RoastMaster Utilities Progress

I finally got a rudimentary  GUI for my RoastMaster Utilities working.

2016-02-26 (1)

Here is the code with a brief explanation of the problem spot. If I had a bit of experience with python classes and inheritance, I probably wouldn’t have had problems.

from PyQt5 import QtCore, QtGui, QtWidgets
import coffeeMenu as cm
import RMPasteData as pd
import sys

from RMUtility2 import Ui_MainWindow


class MyWindow(Ui_MainWindow):
    '''
    Inherit from class created by Qt designer in the file RMUtility2
    The critical part is in the __init__ method (also known as a constructor)
     below. You usually see it as 
     super().__init__() which would call the __init__ method of the parent
     class however Qt Designer doesn't provide an __init__. It provides the
     setupUi method instead.
    '''
    def __init__(self):
        super().setupUi(MainWindow)

    def setupUi(self, MainWindow):
        print("In local setupUI")
        self.coffeeButton.clicked.connect(self.coffeeMenu)
        self.pasteDataButton.clicked.connect(self.pasteData)

    def coffeeMenu(self):
        debug = False
        roastmaster_db = 'C:/Users/kor/Dropbox/Apps/Roastmaster/Kor Database.sqlite'
        # roastmaster_db = 'c:/users/kor/dropbox/apps/roastmaster/Kor Database.sqlite'
        cm.check_db(roastmaster_db)
        cm.show_coffee_list(debug)
        cm.create_report()

    def pasteData(self):
        print("In pastData - local")
        debug = False
        roastmaster_db = 'c:/users/kor/dropbox/apps/roastmaster/Kor Database.sqlite'
        # roastmaster_db = 'C:/Users/kiley_000/Dropbox/Apps/Roastmaster/My Database.sqlite'
        pd.check_db(roastmaster_db)
        pd.show_coffee_list()
        pd.create_report()

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = MyWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())

More PyQt tutorials

I’ve skipped to a new series of PyQt tutorials. This one was produced by Sentdex. I’m sure the guy must have a name but I’m yet to hear it. Anyway, he’s produced a slew of videos on Python programming and many of them are specifically for PyQt4 programming. He recommends PyQt4 over PyQt5–says it is simpler but I would rather work with 5 and I’m not even sure it’s possible to simultaneously have both 4 and 5 environments. I seem to be having a few problems with that scenario.

Sentdex has a web site called pythonprogramming.net. He also has a $5/month subscription plan that allows you to download the videos, take quizzes, ask questions, etc. I signed up for the subscription plan.

And I’ve just discovered another series of videos for using PyQt and the Qt Designer. Here is one of the videos on You Tube.