Connections <hints> section in UI file - qt

I am analyzing xml containing UI generated by Qt Designer. I came across entries whose meaning I do not understand. They concern signal/slot connections:
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
What information does the <hints> section contain? I haven't found anything about it in the documentation while it's hard to guess what the hints and labels mean.

The <hint> have information about the position of the arrow that are used to connect the signals and slots in QtDesigner

Related

QWizardPage designed in Qt Creater can not set geometry correctly when title is set

I am trying to design QWizardPage using Qt Creater.
Everything goes fine if I don't set the title of the wizardpage.
However, when I set the title, the wizard I got is strange. The title takes a large space and the wizard page can not be shown completely.
What I got in Qt Creator is:
But what I got using the generated python code is, the widget I added can not be show completely:
It seems that the size of the wizardpage widget is set to the same as canvas in the Qt Creator, and doesn't spare some space for the title. In other words, designing QWizardPage in Qt Creator doesn't take the space that the title occupies in consideration, and got a wrong geometry setting. How can I use Qt Creator to design a QWizardPage.
The following is how to reproduce my problem:
I use File->New File or Project, and choose Qt->Qt Designer Form, then in the "choose a form template", I choose QWizardPage. Then after I finish designing in the Qt creater, I convert the ui file to PyQt code by using pyuic5 wizard.ui -o wizard.py. I follow this link to generate python code.
The following is my ui file, which is quite simple
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WizardPage</class>
<widget class="QWizardPage" name="WizardPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<property name="title">
<string>This is the tile</string>
</property>
<widget class="QGraphicsView" name="graphicsView">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>351</width>
<height>261</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
My generated python file is:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'qtcchess\wizardpage.ui'
#
# Created by: PyQt5 UI code generator 5.15.6
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_WizardPage(object):
def setupUi(self, WizardPage):
WizardPage.setObjectName("WizardPage")
WizardPage.resize(400, 300)
self.graphicsView = QtWidgets.QGraphicsView(WizardPage)
self.graphicsView.setGeometry(QtCore.QRect(20, 20, 351, 261))
self.graphicsView.setObjectName("graphicsView")
self.retranslateUi(WizardPage)
QtCore.QMetaObject.connectSlotsByName(WizardPage)
def retranslateUi(self, WizardPage):
_translate = QtCore.QCoreApplication.translate
WizardPage.setWindowTitle(_translate("WizardPage", "WizardPage"))
WizardPage.setTitle(_translate("WizardPage", "This is the tile"))
And my main file for testing is:
from PyQt5 import QtCore, QtGui, QtWidgets
from wizardpage import *
from PyQt5.Qt import *
from PyQt5.QtCore import *
import sys
class test_wizard_page(QtWidgets.QWizardPage, Ui_WizardPage):
def __init__(self, parent):
super().__init__(parent)
self.setupUi(self)
class MyWizard(QtWidgets.QWizard):
def __init__(self):
super().__init__()
self.test_wizard_page = test_wizard_page(self)
self.addPage(self.test_wizard_page)
if __name__ == "__main__":
app = QApplication(sys.argv)
wizard = MyWizard()
wizard.show()
sys.exit(app.exec_())
You must use layout managers. Right click on an empty area of the wizard page, and select a vertical or horizontal layout from the "Lay out" submenu.

Confusing outputs with IMPORTXML & IMPORTHTML

I just started with web scrape using Google sheet and would like to seek clarity on the issues below.
Here is the screenshot which will help to illustrate the issues:
Formula used
A28 =IMPORTXML("https://www.thehuboug.com/collections/all?limit=100&sort=price+asc","//div[#class='grid__item small--one-half medium--one-half large--one-quarter']/a/#href")
B28 =CONCATENATE("https://www.thehuboug.com",A28)
C28 =IMPORTXML(B28,"//div[#class='grid__item large--one-half']/h1")
D28 =TRANSPOSE(INDEX(IMPORTHTML(B28,"table"),,2))
Questions
I couldn't figure out why C28 couldn't get the data but C29 has no issue with getting the data.
D28 is able to get the data but not for D29:D33
When I changed https -> http, I was able to get data for D34 and not C34. What does this mean?
Initially, when I first put in my formula, everything will be extracted accordingly. However, on the next day when I re-open the file again, I started to get results like this, with error Resource at url not found. If I copy the same formula on a new sheet, everything will work accordingly again. Overall, I am pretty confused about the behaviour here and would like to understand what can be improved to solve this.
Thanks in advance for helping me in this!
A28:
=IMPORTXML(
"https://www.thehuboug.com/collections/all?limit=100&sort=price+asc",
"//div[#class='grid__item small--one-half medium--one-half large--one-quarter']/a/#href")
B28:
=ARRAYFORMULA("https://www.thehuboug.com"&SUBSTITUTE(A28:A60, "/collections/all",, 1))
C28 and drag down:
=IMPORTXML(B28, "//div[#class='grid__item large--one-half']/h1")
D28 and drag down:
=IFERROR(TRANSPOSE(INDEX(IMPORTHTML(B28, "table"),,2)))

Mapbox Bright wont render: Did I leave a command out?

Using Folium but cant render a map with a "Mapbox Bright" tiling. However I can render a "Stamen Toner" tiling. Am I leaving out a command?
Ran code on both windows and linux platforms,
in the cloud and local,
in both firefox and chrome.
libraries installed via pip install folium or conda install
Code should execute:
import webbrowser
import folium
world_map_stamen = folium.Map(location=[56.130, -106.35], tiles="Stamen Toner",zoom_start=4,height=500, width=1000)
world_map_mapbox = folium.Map(location=[56.130, -106.35], tiles="Mapbox Bright",zoom_start=4,height=500, width=1000)
world_map_stamen.save("mymap_stamen.html")
world_map_mapbox.save("mymap_mapbox.html")
webbrowser.open("mymap_stamen.html")
webbrowser.open("mymap_mapbox.html")
I expected both to work. Only one did. I must be forgetting something?
Found my own answer and this question has been answered elsewhere in various forms....
But it seem like there are two answers:
(1) Mapbox maps are no longer supported in folium 0.9 so Mapbox maps must be called using an attribution and custom tile call:
mymap = folium.Map(location=[30,-83], zoom_start=2,tiles= tileset_id,
attr="any text here")
where tileset_id = "http://api.mapbox.com/v4/mapbox.light/{z}/{x}/{y}.png?access_token=pk.xxx" (where pk.xxx is your API token from mapbox (go sign up))
see https://gis.stackexchange.com/questions/203062/how-do-i-use-mapbox-tiles-with-folium
(2) the tilesets that are free are listed in another post and no longer include mapbox bright. see
https://gis.stackexchange.com/questions/244788/map-ids-to-add-mapbox-basemaps-to-leaflet-or-openlayers

Add multiple children to an xml object without using a loop

My objective is to create an xml object that comprises multiple elements that each contain varying information. A simple example of what the xml object looks like is:
library(xml2)
x1 <- read_xml("<Diag><line level='3' description='a log message'/><line level='3' description='a second log message'/></Diag>")
message(x1)
Which outputs:
<Diag>
<line level="3" description="a log message"/>
<line level="3" description="a second log message"/>
</Diag>
At the moment, I take the information from a data frame called diag. I add the children using a for loop:
library(xml2)
diag <- data.frame(level=c(3,3),description=c('a log message','a second log message'),stringsAsFactors = F)
x2 <- xml_new_root("Diag")
for (i in 1:dim(diag)[1]) {
xml_add_child(.x=x2,.value="line",level=diag$level[i],description=diag$description[i])
}
message(x2)
The xml layout of which is identical to that of x1.
However, this loop is less elegant than I would like it to be, and, for large data frames, can be slow.
My question is: is there any way that I can create multiple children at once using the data in my data frame, by using something akin to apply?
I have tried various options but none were successful and I am not sure I was close enough to post any of these options here. Currently, I am using the xml2 package but if a solution can be found using another package then I'd be open to that also.
Much obliged for any help!
The following seems to be doing what you want, using sapply as requested.
x2 <- xml_new_root("Diag")
sapply(1:dim(diag)[1], function(i) {
xml_add_child(.x=x2,.value="line",level=diag$level[i],description=diag$description[i])
}
)
message(x2)
<?xml version="1.0" encoding="UTF-8"?>
<Diag>
<line level="3" description="a log message"/>
<line level="3" description="a second log message"/>
</Diag>

R: Hide worksheet with package xlsx

I've had great success with the R package xlsx for many things. However, in the documentation, it says "the user has control to set colors, fonts, data formats, add borders, hide/unhide sheets, add/remove rows, add/remove sheets, etc." (Emphasis mine.)
However, I've scoured the documentation and can't find the function to hide sheets. Can someone point me to it? Thanks!
Documentation at http://cran.r-project.org/web/packages/xlsx/xlsx.pdf if this helps.
So that others having the same problem can find the answer, here is how developer Adrian Dragulescu replied to my email:
Once you have a workbook
wb <- createWorkbook()
you can do
wb$setSheetHidden(0L, 1L)
if you want to hide the first sheet (0-based indexing in Java).
See the documentation here: http://poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/XSSFWorkbook.html#setSheetHidden(int, int)
I can confirm this works, and many thanks to Mr. Dragulescu.
A solution using openxlsx package:
openxlsx::addWorksheet(worksheetName, sheetName, visible = F) #hides
openxlsx::addWorksheet(worksheetName, sheetName, visible = F) #shows (default)
More info here: https://rdrr.io/cran/openxlsx/man/addWorksheet.html

Resources