小编use*_*529的帖子

PyQt:如何创建可滚动窗口

我认为在 PyQt 中创建可滚动窗口应该更容易。我有一个超出窗口的标签列表,我想向下滚动以查看它们。目前,代码没有给我错误,但窗口没有出现:

class Example(QWidget):

    def __init__(self):
        super().__init__()

        layout = QVBoxLayout()

        lbl_arr = makeLabelArr()

        for i in range(1,8):
            qb = lbl_arr[i]
            # qb.setFixedWidth(300)
            layout.addWidget(qb)

        layout.setAlignment(Qt.AlignTop)

        scroll = QScrollArea()
        scroll.setWidget(self)
        scroll.setWidgetResizable(True)
        scroll.setFixedHeight(400)

        layout.addWidget(scroll)

        self.setLayout(layout)


        self.setGeometry(0, 0, 600, 220)
        self.setWindowTitle('SnP watchlist')

        self.show()


if __name__ == '__main__':

    app = QApplication(sys.argv)
    #print(QDesktopWidget().availableGeometry())

    ex = Example()
    sys.exit(app.exec_())
Run Code Online (Sandbox Code Playgroud)

python pyqt scrollbar qscrollarea

10
推荐指数
1
解决办法
2万
查看次数

Python WebBrowser在同一个选项卡中打开

运行这一行:

webbrowser.open(page.path, new=0, autoraise=True)
Run Code Online (Sandbox Code Playgroud)

我总是在一个新标签中打开页面.

如何使用new = 0在同一个Tab中获取它?

python-webbrowser

9
推荐指数
1
解决办法
907
查看次数

D3 Zoom 无法读取未定义的属性“转换”

我正在尝试使用一个简单的d3.zoom以下简单教程,但我总是遇到我不明白的相同错误。

这是我的代码:

  let svg = d3.select(".chart_container")
  .append("svg")

  let g = svg.append('g')
    .attr("transform", `translate(200px, 200px)`);

  var zoom_handler = d3.zoom()
    .on("zoom", zoom_actions);

  //specify what to do when zoom event listener is triggered 
  function zoom_actions(){
    g.attr("transform", d3.event.transform);
  }

  //add zoom behaviour to the svg element 
  //same as svg.call(zoom_handler); 
  zoom_handler(g);
Run Code Online (Sandbox Code Playgroud)

但我收到此错误:

Uncaught TypeError: Cannot read property 'transform' of undefined
Run Code Online (Sandbox Code Playgroud)

d3.event改变了吗?还是我做错了什么?

javascript d3.js

6
推荐指数
1
解决办法
1203
查看次数

在画布里面的网刮图像

我正在网页抓取一个页面,其中各种数字也出现在小价格图表的图像.

如果我在浏览器中单击此图像,我可以将该图表保存为.png图像.

当我查看元素在检查时看起来像这样的源代码时:

<div class="performance_2d_sparkline graph ng-isolate-scope ng-scope" x-data-percent-change-day="ticker.pct_chge_1D" x-sparkline="watchlistData.sparklineData[ticker.ticker]">
  <span class="inlinesparkline ng-binding">
    <canvas width="100" height="40" style="display: inline-block; width: 100px; height: 40px; vertical-align: top;">
    </canvas>
  </span>
</div>
Run Code Online (Sandbox Code Playgroud)

有没有什么方法可以通过网页抓取我可以通过浏览器手动保存的相同图像?

python canvas image beautifulsoup web-scraping

5
推荐指数
1
解决办法
1837
查看次数

在 Rust 中 Repl 作为 Haskell 中的 GHCI?

作为一个新手,在 Haskell 中很容易理解它是如何工作的,如果你正在寻找一个可以做某事的函数,你可以在 Hoogle 上查找签名/类型。

同时,如果您有一个不太了解其工作原理的函数,您可以在 ghci repl 中查找签名类型,并使用它。

每次我最终用谷歌搜索时,我都在努力使用 Rust 来获得相同类型的体验。难道没有 Rust 的替代品吗?我能得到类似于Haskell的体验吗?

例如,了解如何操作的最佳方法&str是查看在线文档?并通过方法?doc.rust-lang.org?或者有没有一种更类似于 Haskell 的方法?

rust

5
推荐指数
0
解决办法
136
查看次数

从 PythonAnywhere 抓取

I have a free account on PythonAnywhere from where I am trying to run the following script that locally works just fine.

I am wondering if the error I get is for technical reasons or just that PythonAnywhere forbids people to scrap from their platform for certain websites only?

Do you know of other free websites where I would be allowed to scrap anything?

import requests
from bs4 import BeautifulSoup as bs

def scrapMarketwatch(address):
    #creating formatting data from scrapdata
    r …
Run Code Online (Sandbox Code Playgroud)

beautifulsoup web-scraping pythonanywhere

1
推荐指数
1
解决办法
1369
查看次数

Puppeteer 不可视化完整的 SVG 图表

我在 Try Puppeteer 中使用此代码:

const browser = await puppeteer.launch();

const page = await browser.newPage();
await page.goto('https://www.barchart.com/futures/quotes/ESM19/interactive-chart/fullscreen');

const linkHandlers = await page.$x("//li[contains(text(), '1D')]");

if (linkHandlers.length > 0) {
  await linkHandlers[0].click();
} else {
  throw new Error("Link not found");
}

await page.$eval('input[name="fieldInput"]', el => el.value = '1');

console.log(await page.content())
// const text = page.evaluate(() => document.querySelector('rect'))
// text.then((r) => {console.log(r[0])})

await page.screenshot({path: 'screenshot.png'});

await browser.close();
Run Code Online (Sandbox Code Playgroud)

Chrome 浏览器中加载的同一页面显示了指示价格变动的条形图,但在 Puppeteer 中获得的屏幕截图中,图表是空的。

page.content()给出了一个与我在 Chrome 中检查元素时看到的完全不同的 html。

javascript node.js web-scraping puppeteer

0
推荐指数
1
解决办法
1683
查看次数