i am using ruby-gtk. There is a notebook in my application. I added textView to scrolledWindow. I want to get textView buffer. My some code
editor = Textview.new
swin = Gtk::ScrolledWindow.new
tab = Gtk::Notebook.new
swin.add(editor)
tab.append_page(swin, Gtk::Label.new("Tab")
tab.get_nth_page(current_page).buffer # wrong because its contain is a scrolledWindow
How can i get editor buffer?
As GtkScrolledWindow is a GtkBin, you can make use of child method to get the widget added as the child. In your case it should return GtkTextView. Try something on the lines of:
tab.get_nth_page(current_page).child.buffer
Hope this helps!
Related
I'm creating a tool bar in PyQt. How it looks now is:
(HomeButton).............................................(ExitButton)..|
I want to use the space in the middle to put in an image/logo -- with no function so it looks like:
(homebutton)......[IMAGE/LOGO_HERE]......(exitbutton)..|
I've tried to do this by adding a widget with an image but it's not showing up. My code is:
logo = QWidget()
logolabel = QLabel(p3logo)
logopixmap = QPixmap(self.LOGO)
logolabel.setPixmap(QPixmap(self.LOGO))
logolabel.setPixmap(logopixmap)
logo.resize(logopixmap.width(),logopixmap.height())
###logoAction = QAction(QIcon('logo.png'), 'Logo', self)
spacer = QWidget()
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
exitAction = QAction(QIcon('exit.png'), 'Exit', self)
exitAction.setShortcut('Ctrl+X')
exitAction.triggered.connect(self.exitClicked)
homeAction = QAction(QIcon('home.png'), 'Home', self)
homeAction.setShortcut('Ctrl+H')
homeAction.triggered.connect(self.homeClicked)
self.toolbar = self.addToolBar('Toolbar')
self.toolbar.addAction(homeAction)
self.toolbar.addWidget(logo)
###self.toolbar.addAction(logoAction)
self.toolbar.addWidget(spacer)
self.toolbar.addAction(exitAction)
self.toolbar.addSeparator()
I also tried to add it in as an 'icon' but it was resized to the same size as the home/exit buttons making it hardly visible.
Your code example is effectively just adding an empty widget to the toolbar, because the label has not been put inside a layout. It looks like it can be fixed by getting rid of the container widget and simply adding the label directly:
self.toolbar.addWidget(logolabel)
I use a custom keyboard which contains a delete and a clear button.I can able to delete the letters using this code
let obj = UIInputViewController()
(obj.textDocumentProxy as UIKeyInput).deleteBackward()
Is it any keyword available to clear whole text in a textfield.
NB: I found this link but it is not apt for my requirement
There is no keyword available for deleting the whole text in the textfield through custom keyboard.
To clear all the text that the UITextDocumentProxy object can access in the textfield before the cursor position
if let word:String = self.textDocumentProxy.documentContextBeforeInput
{
for _: Int in 0 ..< word.characters.count {
self.textDocumentProxy.deleteBackward()
}
}
To delete the text after cursor position, you have to move the cursor forward to delete it.
I am trying to learn selenium by automating amazon.in
I would like to click on a moving image in an e-spot. It seems there is no class or id. Then how can i proceed?
WebDriver driver= new FirefoxDriver();
#Test
public void test() {
driver.get("http://amazon.in");
driver.manage().window().maximize();
WebElement menu = driver.findElement(By.xpath("//li[#id='nav_cat_2']"));
Actions builder = new Actions(driver);
builder.moveToElement(menu).build().perform();
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//a[#class='nav_a nav_item' and .=\"All Books\"]")));
WebElement menuOption = driver.findElement(By.xpath("//a[#class='nav_a nav_item' and .=\"All Books\"]"));
menuOption.click();
I have reached on the page. But dont know how to proceed after that.
URL
http://www.amazon.in/Books/b/ref=nav_shopall_books_all/280-9259056-7717210?_encoding=UTF8&node=976389031
As I can see, the images are getting scrolled, so just wait for the concerned image first and then click on it. I have added a code based on that:
wait = new WebDriverWait(driver,60);
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//div[#class='acsux-hero-wrap']//li[2]//img")));
WebElement ele = driver.findElement(By.xpath("//div[#class='acsux-hero-wrap']//li[2]//img"));
ele.click();
In the above code, the driver waits till the visibility of the 2nd image is located under 60 seconds. Then, it clicks on that element.
Similarly you can just replace the number li[2] with "li[1]" for first element, "li[4]" for fourth element, and so on.
Use other attributes such as width or alt
//img[contains(#alt,'Children')]
I was able to click on the highlighted image shown in your screenshot although its a different image with different keywords i reckon you'll need some bonded attribute for that image there to be able to click it regardless of its content or so and that'll be something like know the exact div the img tag this and so on.
hope this helps
I found this function to remove a gui element but i think it is outdated. So far I haven't been able to find anyone else who knows how to remove any part of a gui, whether its an entire dat.GUI() or just an added element to a dat.GUI(). The first would probably be enough for what i need (just removing the dat.GUI() all together) but either one would be super helpful!
supposed to remove a dat.GUI()
gui = new dat.GUI();
...
removeGui(gui);
function removeGui(gui, parent)
{
if(!parent)
{
parent = dat.GUI.autoPlaceContainer;
}
parent.removeChild(gui.domElement);
}
But gives back the error: cannot call method 'removeChild' of undefined, so i am guessing that autoPlaceContainer is wrong.
The original author of this function left these notes:
where the parameters gui represents the DAT.GUI you want to remove and parent is the parent container where if you didn't specify a domElement when instantiating DAT.GUI then you don't need to pass a parent.
var gui = new dat.GUI();
item = gui.add(text, 'message');
To delete:
gui.remove(item);
If your item is inside a folder, you have to do:
folder.remove(item);
If you want to remove the entire dat.GUI element along with all of its listeners, you can use gui.destroy()
If you want to reset the dat.GUI's values, you can use datGUI.__controllers.forEach(controller => controller.setValue(controller.initialValue));
You can delete dat.GUI element like this:
gui.remove()
You can try hiding it using:
gui.hide()
Change the remove function in the dat.gui.js file: "slice" wants to be "splice".
The answer can be found here: https://github.com/ulyssesp/dat.gui/commit/86f43c0be5db08c9a6d7339aa8287620306fb0b5
I am relatively new to the Win32/Windows API (non-MFC), and am trying to change the text colour of a static text control. It is already drawn to the screen in black, but I want to change it to another colour using the Windows Colour Chooser dialog, which is opened on clicking a button. Is this possible?
For the button, the WM_COMMAND message is handled on clicking. So far, I have written:
CHOOSECOLOR ccColour;
ccColour.lStructSize = sizeof(ccColour);
ccColour.hwndOwner = hWnd;
ccColour.rgbResult = crLabelTextColour;
ccColour.Flags = CC_FULLOPEN | CC_RGBINIT;
if (ChooseColor(&ccColour) == TRUE)
{
// crLabelTextColour is a COLORREF global variable assigned on loading the program
crLabelTextColour = ccColour.rgbResult;
}
This code, however, fails with an unhandled exception at the if statement, and I'm not sure why! Other examples seem to write code like this.
ChooseColor() crashes because you are not initializing the CHOOSECOLOR structure completely. You are only setting 3 fields, the rest will contain garbage. You'll need to zero-initialize everything, simple to do:
CHOOSECOLOR ccColour = {0};