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!

Finished Building My New Computer Yesterday

My CPU cooler arrived the day before yesterday in the evening so I finished assembling and testing yesterday! Here is the final parts list:

https://pcpartpicker.com/builds/edit/?userbuild=gQ6scf

And here is a short article I wrote for the Completed Builds section of PCPartPicker’s web site.

P.S. I’m waiting for rebates for Video Card and Motherboard.

Here are some things that I’m learning about this build.

  • Samsung SSD 960 EVO 500GB NVMe m.2
    • Install Samsung Magician to manage it.
    • This SSD is supposed to be good for 400TB of writes.
DateDeliveryComponentDescriptionSupplierPriceTaxShippingTotalNotes
6/3/17 CPUIntel – Core i7-7700K 4.2GHz Quad-Core ProcessorNewegg$339.99  $339.99 
6/2/17 CoolerNoctua NH-D14 6 Heatpipe Dual Radiator with 140mm/120mm Dual SSO Bearing Fans CPU CoolerAmazon$69.95  $69.95 
6/12/17 CoolerNoctua NH-D14 6 Heatpipe Dual Radiator with 140mm/120mm Dual SSO Bearing Fans CPU CoolerAmazon-$58.72  -$58.72 
6/12/17 CoolerNoctua NH-D15 6 heatpipe with Dual NF-A15 140mm fansAmazon$89.95  $89.95 
6/3/17 MotherboardASRock Motherboard Z270 TaichiNewegg$209.99  $209.99minus $10 rebate
6/2/17 CaseFractal Design Define R5 Blackout Edition Computer Case FD-CA-DEF-R5-BKONewegg$109.99$7.70 $117.69 
6/3/17 Windows 10Microsoft Windows 10 Pro | USB Flash DriveAmazon$181.50$12.71 $194.21 
5/28/175/31/17StorageSamsung – 960 EVO 500GB M.2-2280 Solid State DriveB&H$219.99$0.00 $219.99 
5/31/176/2/17RAMG.SKILL Ripjaws V Series 32GB (4 x 8GB) 288-Pin DDR4 SDRAM DDR4 3000 (PC4 24000) Intel Z170 Platform Desktop Memory Model F4-3000C15Q-32GVRBNewegg$237.99$10.98 $248.97237.99 with gift card
6/3/17 Video CardEVGA GeForce GTX 1080 FTW GAMING ACX 3.0, 8GB GDDR5X, RGB LED, 10CM FAN, 10 Power Phases, Double BIOS, DX12 OSD Support (PXOC) Graphics Card 08G-P4-6286-KRNewegg$529.99 $13.63$543.62minus $20 rebate
6/2/17 Power SupplyEVGA SuperNOVA 650 G2, 80+ GOLD 650W, Fully ModularAmazon$84.53$5.92 $90.45 
6/2/17 Wrist StrapRosewill ESD Anti-Static Wrist Strap Components RTK-002, Black/YellowAmazon$5.99$0.42 $6.41 
          
    Total$2,021.14  $2,066.09 

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.

Good PyQt5 tutorial

I’ve been looking for a good PyQt5 tutorial. This is quite a good one. Its one major weakness, though, is that all of the examples I’ve studied so far could have been done much more easily with the Qt designer. Nevertheless, this tutorial is helping me understand better how things are put together when creating a GUI with PyQt.

2016-02-20 (1)
Qt Designer version 5.5.1